From 8ce5fbd1198e5419080612b08fb7bcd3a4256a10 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 6 Dec 2012 18:08:44 -0500 Subject: [PATCH] Explicitly prefer top level VIM module Hopefully resolves #6. --- autoload/nrepl/foreplay_connection.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/autoload/nrepl/foreplay_connection.vim b/autoload/nrepl/foreplay_connection.vim index 9601c0b..5236c27 100644 --- a/autoload/nrepl/foreplay_connection.vim +++ b/autoload/nrepl/foreplay_connection.vim @@ -178,11 +178,13 @@ endif ruby << require 'timeout' require 'socket' -def VIM.string_encode(str) - '"' + str.gsub(/[\000-\037"\\]/) { |x| "\\%03o" % (x.respond_to?(:ord) ? x.ord : x[0]) } + '"' -end -def VIM.let(var, value) - VIM.command("let #{var} = #{string_encode(value)}") +class << ::VIM + def string_encode(str) + '"' + str.gsub(/[\000-\037"\\]/) { |x| "\\%03o" % (x.respond_to?(:ord) ? x.ord : x[0]) } + '"' + end + def let(var, value) + VIM.command("let #{var} = #{string_encode(value)}") + end end .