[Vim-latex-cvs] SF.net SVN: vim-latex: [1013] trunk/vimfiles/ftplugin/latex-suite
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2006-04-29 02:36:33
|
Revision: 1013 Author: srinathava Date: 2006-04-28 19:36:23 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/vim-latex/?rev=1013&view=rev Log Message: ----------- Bug: In vim7, 'exe pos' doesn't seem to always work. Sometimes it leads to a spurious double-quote being inserted into the text. I have no idea why this happens. However, using vim's native setpos() when available seems to not have this problem. Fix: When setpos/getpos() are available use them instead. Two new utility functions Tex_(Set|Get)Pos() have been provided. Use these henceforth to record/restore cursor position. New: Expand ... to \dots also when the package ellipsis is detected. Modified Paths: -------------- trunk/vimfiles/ftplugin/latex-suite/compiler.vim trunk/vimfiles/ftplugin/latex-suite/custommacros.vim trunk/vimfiles/ftplugin/latex-suite/elementmacros.vim trunk/vimfiles/ftplugin/latex-suite/envmacros.vim trunk/vimfiles/ftplugin/latex-suite/main.vim trunk/vimfiles/ftplugin/latex-suite/packages.vim trunk/vimfiles/ftplugin/latex-suite/texviewer.vim trunk/vimfiles/ftplugin/latex-suite/version.vim trunk/vimfiles/ftplugin/latex-suite/wizardfuncs.vim Modified: trunk/vimfiles/ftplugin/latex-suite/compiler.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/compiler.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/compiler.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -377,8 +377,6 @@ " compile it. function! Tex_PartCompile() range call Tex_Debug('+Tex_PartCompile', 'comp') - " Save position - let pos = line('.').' | normal! '.virtcol('.').'|' " Get a temporary file in the same directory as the file from which " fragment is being extracted. This is to enable the use of relative path Modified: trunk/vimfiles/ftplugin/latex-suite/custommacros.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/custommacros.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/custommacros.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -196,7 +196,6 @@ let markerString = '<---- Latex Suite End Macro ---->' let _a = @a - let position = line('.').' | normal! '.virtcol('.').'|' silent! call append(line('.'), markerString) silent! exec "read ".fname silent! exec "normal! V/^".markerString."$/-1\<CR>\"ax" Modified: trunk/vimfiles/ftplugin/latex-suite/elementmacros.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/elementmacros.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/elementmacros.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -35,17 +35,13 @@ let s:definedFuncs = 1 " Tex_RemoveElementMenus: remove the elements menu {{{ - " function! Tex_RemoveElementMenus() exe 'silent! aunmenu '.s:lastElementsLocation.'Font.' exe 'silent! aunmenu '.s:lastElementsLocation.'Dimension.' exe 'silent! aunmenu '.s:lastElementsLocation.'Counters.' exe 'silent! aunmenu '.s:lastElementsLocation.'Various.' - endfunction - - " }}} + endfunction " }}} " Tex_FontFamily: sets up font menus {{{ - " function! <SID>Tex_FontFamily(font,fam) let vislhs = matchstr(tolower(a:font), '^.\zs.*') @@ -65,11 +61,8 @@ \" \<C-\\>\<C-N>:call VEnclose('\\text".vislhs."{', '}', '{\\".vislhs.a:fam." ', '}')<CR>" endif - endfunction - - " }}} + endfunction " }}} " Tex_FontDiacritics: sets up menus for diacritics. {{{ - " function! <SID>Tex_FontDiacritics(name, rhs) let location = s:fontMenuLoc.'&Diacritics.'.a:name.'<tab>' exe 'amenu '.location. @@ -78,14 +71,12 @@ \" \<C-\\>\<C-n>:call VEnclose('\\".a:rhs."{', '}', '', '')<CR>" endfunction " }}} " Tex_FontSize: sets up size fonts {{{ - " function! <SID>Tex_FontSize(name) let location = s:fontMenuLoc.'&Size.'.a:name.'<tab>' exe 'amenu '.location." <plug>\\".a:name exe 'vunmenu '.location endfunction " }}} " Tex_Fontfont: sets up the 'font' part of font menus {{{ - " function! <SID>Tex_Fontfont(desc, lhs) let location = s:fontMenuLoc.'&font.'.a:desc.'<tab>' exe "amenu ".location." <plug><C-r>=IMAP_PutTextWithMovement('".a:lhs."')<CR>" @@ -109,6 +100,7 @@ exe "amenu ".location." <plug><C-r>=IMAP_PutTextWithMovement('".a:lhs."')<CR>" exe "vunmenu ".location endfunction " }}} + endif " }}} Modified: trunk/vimfiles/ftplugin/latex-suite/envmacros.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/envmacros.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/envmacros.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -519,7 +519,7 @@ return Tex_ChooseFromPrompt( \ a:ask."\n" . \ Tex_CreatePrompt(g:Tex_PromptedEnvironments, 2, ",") . - \ "\nEnter nae or number of environment :", + \ "\nEnter name or number of environment :", \ g:Tex_PromptedEnvironments, ",") endfunction " }}} " Tex_DoEnvironment: fast insertion of environments {{{ @@ -642,7 +642,7 @@ function! Tex_FastEnvironmentInsert(isvisual) let start_line = line('.') - let pos = line('.').' | normal! '.virtcol('.').'|' + let pos = Tex_GetPos() let s:isvisual = a:isvisual " decide if we are in the preamble of the document. If we are then @@ -660,11 +660,11 @@ if start_line < begin_line " return to our original location and insert a package " statement. - exe pos + call Tex_SetPos(pos) return Tex_package_from_line() else " we are after the preamble. insert an environment. - exe pos + call Tex_SetPos(pos) return Tex_DoEnvironment() endif @@ -672,13 +672,13 @@ " if there is only a \documentclass but no \begin{document}, then " the entire file is a preamble. Put a package. - exe pos + call Tex_SetPos(pos) return Tex_package_from_line() else " no \documentclass, put an environment. - exe pos + call Tex_SetPos(pos) return Tex_DoEnvironment() endif @@ -889,13 +889,13 @@ " " Author: Alan Schmitt function! Tex_GetCurrentEnv() - let pos = line('.').' | normal! '.virtcol('.').'|' + let pos = Tex_GetPos() 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 + call Tex_SetPos(pos) return '' endif if match(getline(env_line), '^[^%]*\\begin{') == -1 @@ -906,7 +906,7 @@ " 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 + call Tex_SetPos(pos) return env else " this \\begin closes a \\end, continue searching. @@ -1071,7 +1071,7 @@ " function! Tex_ChangeCommand(isvisual) - let pos_com = line('.').' | normal! '.virtcol('.').'|' + let pos_com = Tex_GetPos() let com_line = searchpair('\\\k\{-}{', '', '}', 'b') @@ -1082,7 +1082,7 @@ if !exists('com_name') echomsg "You are not inside command" - exe pos_com + call Tex_SetPos(pos_com) return 0 endif @@ -1090,11 +1090,11 @@ let change_com = PromptForCommand('Do you want to change it to (number or name)? ') if change_com == '' - exe pos_com + call Tex_SetPos(pos_com) return 0 else call <SID>ChangeCommand(change_com) - exe pos_com + call Tex_SetPos(pos_com) return 0 endif Modified: trunk/vimfiles/ftplugin/latex-suite/main.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/main.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/main.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -639,7 +639,24 @@ endif return retval endfunction " }}} +" Tex_GetPos: gets position of cursor {{{ +function! Tex_GetPos() + if exists('*getpos') + return getpos('.') + else + return line('.').' | normal! '.virtcol('.').'|' + endif +endfunction " }}} +" Tex_SetPos: sets position of cursor {{{ +function! Tex_SetPos(pos) + if exists('*setpos') + call setpos('.', a:pos) + else + exec a:pos + endif +endfunction " }}} + " ============================================================================== " Smart key-mappings " ============================================================================== @@ -772,7 +789,7 @@ function! <SID>SmartDots() if strpart(getline('.'), col('.')-3, 2) == '..' && - \ g:Tex_package_detected =~ '\<amsmath\>' + \ g:Tex_package_detected =~ '\<amsmath\|ellipsis\>' return "\<bs>\<bs>\\dots" elseif synIDattr(synID(line('.'),col('.')-1,0),"name") =~ '^texMath' \&& strpart(getline('.'), col('.')-3, 2) == '..' Modified: trunk/vimfiles/ftplugin/latex-suite/packages.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/packages.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/packages.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -311,7 +311,7 @@ function! Tex_ScanForPackages(...) call Tex_Debug("+Tex_ScanForPackages", "pack") - let pos = line('.').' | normal! '.virtcol('.').'|' + let pos = Tex_GetPos() " For package files without \begin and \end{document}, we might be told to " search from beginning to end. @@ -448,7 +448,7 @@ endwhile - exe pos + call Tex_SetPos(pos) " first make a random search so that we push at least one item onto the " search history. Since vim puts only one item in the history per function " call, this way we make sure that one and only item is put into the Modified: trunk/vimfiles/ftplugin/latex-suite/texviewer.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/texviewer.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/texviewer.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -47,7 +47,7 @@ let s:origdir = getcwd() cd %:p:h - let s:pos = line('.').' | normal! '.virtcol('.').'|' + let s:pos = Tex_GetPos() unlet! s:type unlet! s:typeoption @@ -220,7 +220,7 @@ " ``<enter>`` in one of the [Error List] windows which shows the list of " matches. completeword is the rest of the word which needs to be inserted. function! Tex_CompleteWord(completeword) - exe s:pos + call Tex_SetPos(s:pos) " Complete word, check if add closing } exe 'normal! a'.a:completeword."\<Esc>" @@ -476,7 +476,7 @@ exe s:winnum.' wincmd w' pclose! cclose - exe s:pos + call Tex_SetPos(s:pos) endfunction " }}} " Tex_GoToLocation: Go to chosen location {{{ " Description: Get number of current line and go to this number @@ -517,13 +517,13 @@ exec 'split '.Tex_EscapeSpaces(mainfname) endif - let pos = line('.').'| normal! '.virtcol('.').'|' + let pos = Tex_GetPos() if a:what =~ 'bib' call Tex_ScanFileForCite(a:prefix) else call Tex_ScanFileForLabels(a:prefix) endif - exec pos + call Tex_SetPos(pos) q let &path = _path Modified: trunk/vimfiles/ftplugin/latex-suite/version.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/version.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/version.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -24,7 +24,7 @@ " "stabilize" that version by releasing a few pre-releases and then " keep that as a stable point. function! Tex_Version() - return "Latex-Suite: version 1.8.19" + return "Latex-Suite: version 1.8.21" endfunction com! -nargs=0 TVersion echo Tex_Version() Modified: trunk/vimfiles/ftplugin/latex-suite/wizardfuncs.vim =================================================================== --- trunk/vimfiles/ftplugin/latex-suite/wizardfuncs.vim 2006-04-28 16:48:12 UTC (rev 1012) +++ trunk/vimfiles/ftplugin/latex-suite/wizardfuncs.vim 2006-04-29 02:36:23 UTC (rev 1013) @@ -59,10 +59,9 @@ return sstructure.toc.shorttitle.ttitle endfunction - " }}} function! Tex_section(...) "{{{ - silent let pos = line('.').' | normal! '.virtcol('.').'|' + silent let pos = Tex_GetPos() silent let last_section_value = s:Tex_section_detection() if a:0 == 0 silent let last_section_name = s:Tex_section_name(last_section_value) @@ -79,10 +78,10 @@ silent let curr_section_name = s:Tex_section_name(curr_section_value) silent call s:Tex_section_call(curr_section_name) endif - silent exe pos + silent call Tex_SetPos(pos) endfunction "}}} function! Tex_section_adv(...) "{{{ - let pos = line('.').' | normal! '.virtcol('.').'|' + let pos = Tex_GetPos() silent let last_section_value = s:Tex_section_detection() if a:0 == 0 silent let last_section_name = s:Tex_section_name(last_section_value) @@ -99,12 +98,12 @@ let section = Tex_InsSecAdv(curr_section_name) endif exe "normal i".section - exe pos + call Tex_SetPos(pos) endfunction "}}} function! s:Tex_section_detection() "{{{ - let pos = line('.').' | normal! '.virtcol('.').'|' + let pos = Tex_GetPos() let last_section1 = search("\\\\\subparagraph\\|\\\\paragraph\\|\\\\subsubsection\\|\\\\subsection\\|\\\\section\\|\\\\chapter\\|\\\part\)", "b") - exe pos + call Tex_SetPos(pos) let last_section2 = search("\\\\\part\\|\\\\chapter\\|\\\\section\\|\\\\subsection\\|\\\\subsubsection\\|\\\\paragraph\\|\\\subparagraph\)", "b") if last_section1 > last_section2 let last_section = last_section1 @@ -132,7 +131,7 @@ else let last_section_value = 0 endif - exe pos + call Tex_SetPos(pos) return last_section_value endfunction "}}} function! s:Tex_section_curr_value(sec_arg) "{{{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |