Permalink
Browse files

Merge pull request #7 from caio/master

Add support for calling custom functions during escape
  • Loading branch information...
2 parents 0c111d3 + ffb3c4e commit c029aec736ade7143bfe9b009f344af4bdf49c1d @jpalardy jpalardy committed Nov 29, 2011
Showing with 16 additions and 1 deletion.
  1. +3 −0 ftplugin/python/slime.vim
  2. +3 −0 ftplugin/scala/slime.vim
  3. +10 −1 plugin/slime.vim
@@ -0,0 +1,3 @@
+function! _EscapeText_python(text)
+ return substitute(a:text, "\n", "", "g")
+endfunction
View
@@ -0,0 +1,3 @@
+function! _EscapeText_scala(text)
+ return ":paste\n" . a:text . ""
+endfunction
View
@@ -73,7 +73,16 @@ endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:_EscapeText(text)
- return substitute(shellescape(a:text), "\\\\\\n", "\n", "g")
+ let transformed_text = a:text
+
+ if exists("&filetype")
+ let custom_escape = "_EscapeText_" . &filetype
+ if exists("*" . custom_escape)
+ let transformed_text = call(custom_escape, [a:text])
+ end
+ end
+
+ return substitute(shellescape(transformed_text), "\\\\\\n", "\n", "g")
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

0 comments on commit c029aec

Please sign in to comment.