Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv2084/ftplugin/latex-suite
Modified Files:
main.vim
Log Message:
Several changes to the s:TexQuotes() function:
* more comments
* fix a bug, introduced in the previous patch, when inserting " in math mode
or after \ .
* Do not assume that the open- and close-quote strings can be distinguished by
their first characters. (German uses "` and "'.)
* Look for buffer-local versions of Tex_SmartQuoteOpen and Tex_SmartQuoteClose
before using the global versions.
Index: main.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/main.vim,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** main.vim 15 Jan 2003 02:54:28 -0000 1.31
--- main.vim 15 Jan 2003 16:16:27 -0000 1.32
***************
*** 178,184 ****
if g:Tex_SmartKeyQuote
! " TexQuotes: inserts `` or '' instead of
" Taken from texmacro.vim by Benji Fisher <be...@e-...>
" TODO: Deal with nested quotes.
function! s:TexQuotes()
let l = line(".")
--- 178,186 ----
if g:Tex_SmartKeyQuote
! " TexQuotes: inserts `` or '' instead of "
" Taken from texmacro.vim by Benji Fisher <be...@e-...>
" TODO: Deal with nested quotes.
+ " The :imap that calls this function should insert a ", move the cursor to
+ " the left of that character, then call this with <C-R>= .
function! s:TexQuotes()
let l = line(".")
***************
*** 188,198 ****
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
execute restore_cursor
if synIDattr(synID(l, c, 1), "name") =~ "^texMath"
\ || (c > 1 && getline(l)[c-2] == '\')
! return '"'
endif
- let open = exists("g:Tex_SmartQuoteOpen") ? g:Tex_SmartQuoteOpen : "``"
- let close = exists("g:Tex_SmartQuoteClose") ? g:Tex_SmartQuoteClose : "''"
let boundary = '\|'
if exists("s:TeX_strictquote")
if( s:TeX_strictquote == "open" || s:TeX_strictquote == "both" )
--- 190,219 ----
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
execute restore_cursor
+ " In math mode, or when preceded by a \, just move the cursor past the
+ " already-inserted " character.
if synIDattr(synID(l, c, 1), "name") =~ "^texMath"
\ || (c > 1 && getline(l)[c-2] == '\')
! return "\<Right>"
! endif
! " Find the appropriate open-quote and close-quote strings.
! if exists("b:Tex_SmartQuoteOpen")
! let open = b:Tex_SmartQuoteOpen
! elseif exists("g:Tex_SmartQuoteOpen")
! let open = g:Tex_SmartQuoteOpen
! else
! let open = "``"
! endif
! if exists("b:Tex_SmartQuoteClose")
! let close = b:Tex_SmartQuoteClose
! elseif exists("g:Tex_SmartQuoteClose")
! let close = g:Tex_SmartQuoteClose
! else
! let close = "''"
endif
let boundary = '\|'
+ " This code seems to be obsolete, since this script variable is never
+ " set. The idea is that some languages use ",," as an open- or
+ " close-quote string, and we want to avoid confusing ordinary ","
+ " with a quote boundary.
if exists("s:TeX_strictquote")
if( s:TeX_strictquote == "open" || s:TeX_strictquote == "both" )
***************
*** 203,210 ****
endif
endif
let q = open
while 1 " Look for preceding quote (open or close), ignoring
" math mode and '\"' .
- " execute 'normal ?^$\|"\|' . open . boundary . close . "\r"
call search(open . boundary . close . '\|^$\|"', "bw")
if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath"
--- 224,231 ----
endif
endif
+ " Eventually return q; set it to the default value now.
let q = open
while 1 " Look for preceding quote (open or close), ignoring
" math mode and '\"' .
call search(open . boundary . close . '\|^$\|"', "bw")
if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath"
***************
*** 214,220 ****
endwhile
" Now, test whether we actually found a _preceding_ quote; if so, is it
! " and open quote?
if ( line(".") < l || line(".") == l && col(".") < c )
! if strlen(getline(".")) && (getline(".")[col(".")-1] == open[0])
if line(".") == l && col(".") + strlen(open) == c
" Insert "<++>''<++>" instead of just "''".
--- 235,242 ----
endwhile
" Now, test whether we actually found a _preceding_ quote; if so, is it
! " an open quote?
if ( line(".") < l || line(".") == l && col(".") < c )
! if strpart(getline("."), col(".")-1) =~
! \ '\V\^' . escape(open, '\')
if line(".") == l && col(".") + strlen(open) == c
" Insert "<++>''<++>" instead of just "''".
|