[Vim-latex-cvs] vimfiles/ftplugin/latex-suite envmacros.vim,1.46,1.47
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2004-03-15 19:49:58
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16873 Modified Files: envmacros.vim Log Message: New: A more precise behavior of the Tex_InsertItem function to account for the fact that the previous \\begin might not be the environment in which the cursor is enclosed. (Alan Schmitt) Index: envmacros.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/envmacros.vim,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** envmacros.vim 14 Mar 2004 06:25:44 -0000 1.46 --- envmacros.vim 15 Mar 2004 19:40:48 -0000 1.47 *************** *** 871,874 **** --- 871,920 ---- " Contributions / Tex_InsertItem() from Johannes Tanzler " ============================================================================== + " Tex_GetCurrentEnv: gets the current environment in which the cursor lies {{{ + " Description: handles cases such as: + " + " \begin{itemize} + " \item first item + " \item second item + " \begin{description} + " \item first desc + " \item second + " % Tex_GetCurrentEnv will return "description" when called from here + " \end{description} + " \item third item + " % Tex_GetCurrentEnv will return "itemize" when called from here + " \end{itemize} + " % Tex_GetCurrentEnv will return "" when called from here + " + " Author: Alan Schmitt + function! Tex_GetCurrentEnv() + let pos = line('.').' | normal! '.virtcol('.').'|' + let i = 0 + while 1 + let env_line = search('^[^%]*\\\%(begin\|end\){', 'bW') + if env_line == 0 + " we reached the beginning of the file, so we return the empty string + exe pos + return '' + endif + if match(getline(env_line), '^[^%]*\\begin{') == -1 + " we found a \\end, so we keep searching + let i = i + 1 + continue + else + " we found a \\begin which has not been \\end'ed. we are done. + if i == 0 + let env = matchstr(getline(env_line), '\\begin{\zs.\{-}\ze}') + exe pos + return env + else + " this \\begin closes a \\end, continue searching. + let i = i - 1 + continue + endif + endif + endwhile + endfunction + " }}} " Tex_InsertItem: insert \item into a list {{{ " Description: Find last \begin line, extract env name, return to the start *************** *** 885,892 **** function! Tex_InsertItem() " Get current enclosing environment ! let pos = line('.').' | normal! '.virtcol('.').'|' ! let env_line = search('^[^%]*\\begin{', 'bW') ! let env = matchstr(getline(env_line), '\\begin{\zs.\{-}\ze}') ! exe pos if exists('g:Tex_ItemStyle_'.env) --- 931,935 ---- function! Tex_InsertItem() " Get current enclosing environment ! let env = Tex_GetCurrentEnv() if exists('g:Tex_ItemStyle_'.env) |