Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv31508
Modified Files:
main.vim
Log Message:
Change: Initially, Tex_EscapeForGrep would always double backslashes at
least once to account for the fact that the user means the external
grep command to see the string ``\\label`` when he passes
``\label`` to this function. But making such guesses is bad for
cases when we want to pass a single ``\`` to the external grep
command (for instance when we want to pass ``\<word\>`` to the
external grep command). Therefore, stop this function from making
any guesses about what the user might have wanted the external
command to see. This function now expects the user to pass the
exact string which he wants the external grep command to see.
Index: main.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/main.vim,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** main.vim 14 Dec 2003 23:31:10 -0000 1.56
--- main.vim 15 Dec 2003 00:53:27 -0000 1.57
***************
*** 531,555 ****
let s:incnum = a:val
endfunction " }}}
! " Tex_EscapeForGrep: escapes \ and " the correct number of times {{{
" Description: This command escapes the backslash and double quotes in a
! " search pattern the correct number of times so it can be used in the :grep
! " command. This command is meant to be used as:
" exec "silent! grep ".Tex_EscapeForGrep(pattern)." file"
function! Tex_EscapeForGrep(string)
! " This first escaping is so that grep gets a string like '\\bibitem' when
! " we want to search for a string like '\bibitem'.
! let retVal = escape(a:string, "\\")
! " The next escape is because when the shellxquote is ", then the grep
! " commad is usually called as
! " bash -c "grep pattern filename"
! " which means that we need to escape backslashes (because they get halved)
! " and also double quotes.
if &shell =~ 'sh'
let retVal = escape(retVal, "\\")
if &shellxquote == '"'
let retVal = escape(retVal, "\"\\")
endif
endif
return retVal
--- 531,566 ----
let s:incnum = a:val
endfunction " }}}
! " Tex_EscapeForGrep: escapes back-slashes and doublequotes the correct number of times {{{
" Description: This command escapes the backslash and double quotes in a
! " search pattern the correct number of times so it can be used in the ``:grep``
! " command. This command is meant to be used as::
! "
" exec "silent! grep ".Tex_EscapeForGrep(pattern)." file"
+ "
+ " The input argument to this function should be the string which you want
+ " the external command to finally see. For example, to search for a string
+ " ``'\bibitem'``, the grep command needs to be passed a string like
+ " ``'\\bibitem'``. Examples::
+ "
+ " Tex_EscapeForGrep('\\bibitem') " correct
+ " Tex_EscapeForGrep('\bibitem') " wrong
+ " Tex_EscapeForGrep("\\bibitem") " wrong
+ " Tex_EscapeForGrep('\<word\>') " correct
+ "
function! Tex_EscapeForGrep(string)
! let retVal = a:string
! " The shell halves the backslashes.
if &shell =~ 'sh'
let retVal = escape(retVal, "\\")
+
+ " If shellxquote is set, then the backslashes are halved yet again.
if &shellxquote == '"'
let retVal = escape(retVal, "\"\\")
endif
+
endif
+ " escape special characters which bash/cmd.exe might interpret
+ let retVal = escape(retVal, "<>")
return retVal
|