[Vim-latex-cvs] vimfiles/ftplugin/latex-suite compiler.vim,1.64,1.65
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2004-05-22 00:26:53
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24309 Modified Files: compiler.vim Log Message: New: A refactoring of code to use Tex_GetVarValue instead of using g:Tex_* variables. Basically, this makes it possible for the user to more finely tune the behavior of latex-suite on a per-project basis. As of now, most settings of latex-suite are handled by setting global variables like g:Tex_UseMakeFile. In the future, we should set "factory defaults" in texrc by setting g:Tex_* variables. After that, we should always use Tex_GetVarValue to query the value of the variable. This allows the user to over-ride the factory default at a variety of levels, for example: 1. If the user defines g:Tex_* in ~/.vim/ftplugin/tex.vim, then he will over-ride the setting for all files. 2. If he defines b:Tex_* in a project master file, for instance, if he sets let b:Tex_UseMakeFile = 0 in one .latexmain file, then only .tex files which source that .latexmain file will not use the makefile. Other files will continue to use the makefile. Index: compiler.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/compiler.vim,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** compiler.vim 18 May 2004 22:23:14 -0000 1.64 --- compiler.vim 22 May 2004 00:26:40 -0000 1.65 *************** *** 11,23 **** function! Tex_SetTeXCompilerTarget(type, target) if a:target == '' ! if g:Tex_DefaultTargetFormat == 'dvi' ! let target = input('Enter the target ([dvi]/ps/pdf/...) for '.a:type.'r: ') ! elseif g:Tex_DefaultTargetFormat == 'ps' ! let target = input('Enter the target (dvi/[ps]/pdf/...) for '.a:type.'r: ') ! elseif g:Tex_DefaultTargetFormat =~ 'pdf' ! let target = input('Enter the target (dvi/ps/[pdf]/...) for '.a:type.'r: ') ! else ! let target = input('Enter the target (dvi/ps/pdf/['.g:Tex_DefaultTargetFormat.']) for '.a:type.'r: ') ! endif else let target = a:target --- 11,16 ---- function! Tex_SetTeXCompilerTarget(type, target) if a:target == '' ! let target = Tex_GetVarValue('Tex_DefaultTargetFormat') ! let target = input('Enter the target format for '.a:type.'r: ', target) else let target = a:target *************** *** 26,34 **** let target = 'dvi' endif ! if exists('g:Tex_'.a:type.'Rule_'.target) if a:type == 'Compile' ! let &l:makeprg = escape(g:Tex_CompileRule_{target}, g:Tex_EscapeChars) elseif a:type == 'View' ! exec 'let s:viewer = g:Tex_'.a:type.'Rule_'.target endif let s:target = target --- 19,29 ---- let target = 'dvi' endif ! ! let targetRule = Tex_GetVarValue('Tex_'.a:type.'Rule_'.target) ! if targetRule != '' if a:type == 'Compile' ! let &l:makeprg = escape(targetRule, Tex_GetVarValue('Tex_EscapeChars')) elseif a:type == 'View' ! let s:viewer = targetRule endif let s:target = target *************** *** 36,40 **** let curd = getcwd() exe 'cd '.expand('%:p:h') ! if glob('makefile*') == '' && glob('Makefile*') == '' if has('gui_running') call confirm( --- 31,35 ---- let curd = getcwd() exe 'cd '.expand('%:p:h') ! if !Tex_GetVarValue('Tex_UseMakefile') || (glob('makefile*') == '' && glob('Makefile*') == '') if has('gui_running') call confirm( *************** *** 53,57 **** endif else ! echomsg 'assuming target is for makefile' let s:target = target endif --- 48,52 ---- endif else ! echomsg 'Assuming target is for makefile' let s:target = target endif *************** *** 62,74 **** function! SetTeXTarget(...) if a:0 < 1 ! if g:Tex_DefaultTargetFormat == 'dvi' ! let target = input('Enter the target for compiler and viewer ([dvi]/ps/pdf/...): ') ! elseif g:Tex_DefaultTargetFormat == 'ps' ! let target = input('Enter the target for compiler and viewer (dvi/[ps]/pdf/...): ') ! elseif g:Tex_DefaultTargetFormat =~ 'pdf' ! let target = input('Enter the target for compiler and viewer (dvi/ps/[pdf]/...): ') ! else ! let target = input('Enter the target for compiler and viewer (dvi/ps/pdf/['.g:Tex_DefaultTargetFormat.']): ') ! endif else let target = a:1 --- 57,62 ---- function! SetTeXTarget(...) if a:0 < 1 ! let target = Tex_GetVarValue('Tex_DefaultTargetFormat') ! let target = input('Enter the target format for compiler and viewer: ', target) else let target = a:1 *************** *** 77,80 **** --- 65,69 ---- let target = 'dvi' endif + call Tex_SetTeXCompilerTarget('Compile', target) call Tex_SetTeXCompilerTarget('View', target) *************** *** 119,123 **** " extracted from *.latexmain (if possible) log file name depends on the " main file which will be compiled. ! if g:Tex_UseMakefile && (glob('makefile') != '' || glob('Makefile') != '') let _makeprg = &l:makeprg let &l:makeprg = 'make $*' --- 108,112 ---- " extracted from *.latexmain (if possible) log file name depends on the " main file which will be compiled. ! if Tex_GetVarValue('Tex_UseMakefile') && (glob('makefile') != '' || glob('Makefile') != '') let _makeprg = &l:makeprg let &l:makeprg = 'make $*' *************** *** 171,175 **** " resize the window to just fit in with the number of lines. exec ( line('$') < 4 ? line('$') : 4 ).' wincmd _' ! if exists('g:Tex_GotoError') && g:Tex_GotoError == 1 call Tex_GotoErrorLocation(mfnlog) else --- 160,164 ---- " resize the window to just fit in with the number of lines. exec ( line('$') < 4 ? line('$') : 4 ).' wincmd _' ! if Tex_GetVarValue('Tex_GotoError') == 1 call Tex_GotoErrorLocation(mfnlog) else *************** *** 201,211 **** call Tex_Debug("Tex_RunLaTeX: compiling to target [".s:target."]", "comp") ! let dependency = s:target ! if exists('g:Tex_FormatDependency_'.s:target) ! if g:Tex_FormatDependency_{s:target} !~ ','.s:target.'$' ! let dependency = g:Tex_FormatDependency_{s:target}.','.s:target ! else ! let dependency = g:Tex_FormatDependency_{s:target} endif endif --- 190,200 ---- call Tex_Debug("Tex_RunLaTeX: compiling to target [".s:target."]", "comp") ! if Tex_GetVarValue('Tex_FormatDependency_'.s:target) != '' ! let dependency = Tex_GetVarValue('Tex_FormatDependency_'.s:target) ! if dependency !~ ','.s:target.'$' ! let dependency = dependency.','.s:target endif + else + let dependency = s:target endif *************** *** 220,224 **** call Tex_Debug('Tex_RunLaTeX: setting target to '.s:target, 'comp') ! if g:Tex_MultipleCompileFormats =~ '\<'.s:target.'\>' call Tex_Debug("Tex_RunLaTeX: compiling file multiple times via Tex_CompileMultipleTimes", "comp") call Tex_CompileMultipleTimes() --- 209,213 ---- call Tex_Debug('Tex_RunLaTeX: setting target to '.s:target, 'comp') ! if Tex_GetVarValue('Tex_MultipleCompileFormats') =~ '\<'.s:target.'\>' call Tex_Debug("Tex_RunLaTeX: compiling file multiple times via Tex_CompileMultipleTimes", "comp") call Tex_CompileMultipleTimes() *************** *** 291,302 **** " because that seems to not work on older bash'es. if s:target == 'dvi' ! if exists('g:Tex_UseEditorSettingInDVIViewer') && ! \ g:Tex_UseEditorSettingInDVIViewer == 1 && \ exists('v:servername') && \ (s:viewer == "xdvi" || s:viewer == "xdvik") let execString = 'silent! !'.s:viewer.' -editor "gvim --servername '.v:servername. \ ' --remote-silent +\%l \%f" '.mainfname.'.dvi &' ! elseif exists('g:Tex_UseEditorSettingInDVIViewer') && ! \ g:Tex_UseEditorSettingInDVIViewer == 1 && \ s:viewer == "kdvi" let execString = 'silent! !kdvi --unique '.mainfname.'.dvi &' --- 280,289 ---- " because that seems to not work on older bash'es. if s:target == 'dvi' ! if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && \ exists('v:servername') && \ (s:viewer == "xdvi" || s:viewer == "xdvik") let execString = 'silent! !'.s:viewer.' -editor "gvim --servername '.v:servername. \ ' --remote-silent +\%l \%f" '.mainfname.'.dvi &' ! elseif Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 \ s:viewer == "kdvi" let execString = 'silent! !kdvi --unique '.mainfname.'.dvi &' *************** *** 342,349 **** " automatically open the DVI viewer irrespective of what the user chose as " the default view format. ! if !exists('g:Tex_ViewRule_dvi') return endif ! let viewer = g:Tex_ViewRule_dvi let curd = getcwd() --- 329,336 ---- " automatically open the DVI viewer irrespective of what the user chose as " the default view format. ! if Tex_GetVarValue('Tex_ViewRule_dvi') == '' return endif ! let viewer = Tex_GetVarValue('Tex_ViewRule_dvi') let curd = getcwd() *************** *** 362,367 **** else ! if exists('g:Tex_UseEditorSettingInDVIViewer') && ! \ g:Tex_UseEditorSettingInDVIViewer == 1 && \ exists('v:servername') && \ (viewer == "xdvi" || viewer == "xdvik") --- 349,353 ---- else ! if Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && \ exists('v:servername') && \ (viewer == "xdvi" || viewer == "xdvik") *************** *** 371,377 **** \ mainfnameRoot.'.dvi &' ! elseif exists('g:Tex_UseEditorSettingInDVIViewer') && ! \ g:Tex_UseEditorSettingInDVIViewer == 1 && ! \ viewer == "kdvi" let execString = 'silent! !kdvi --unique file:'.mainfnameRoot.'.dvi\#src:'.line('.').expand("%").' &' --- 357,361 ---- \ mainfnameRoot.'.dvi &' ! elseif Tex_GetVarValue('Tex_UseEditorSettingInDVIViewer') == 1 && viewer == "kdvi" let execString = 'silent! !kdvi --unique file:'.mainfnameRoot.'.dvi\#src:'.line('.').expand("%").' &' *************** *** 414,428 **** " Remember all the temp files and for each temp file created, remember " where the temp file came from. ! let g:Tex_NumTempFiles = (exists('g:Tex_NumTempFiles') ? g:Tex_NumTempFiles + 1 : 1) ! let g:Tex_TempFiles = (exists('g:Tex_TempFiles') ? g:Tex_TempFiles : '') \ . tmpfile."\n" ! let g:Tex_TempFile_{g:Tex_NumTempFiles} = tmpfile " TODO: For a function Tex_RestoreFragment which restores a temp file to " its original location. ! let g:Tex_TempFileOrig_{g:Tex_NumTempFiles} = expand('%:p') ! let g:Tex_TempFileRange_{g:Tex_NumTempFiles} = a:firstline.','.a:lastline " Set up an autocmd to clean up the temp files when Vim exits. ! if g:Tex_RemoveTempFiles augroup RemoveTmpFiles au! --- 398,412 ---- " Remember all the temp files and for each temp file created, remember " where the temp file came from. ! let s:Tex_NumTempFiles = (exists('s:Tex_NumTempFiles') ? s:Tex_NumTempFiles + 1 : 1) ! let s:Tex_TempFiles = (exists('s:Tex_TempFiles') ? s:Tex_TempFiles : '') \ . tmpfile."\n" ! let s:Tex_TempFile_{s:Tex_NumTempFiles} = tmpfile " TODO: For a function Tex_RestoreFragment which restores a temp file to " its original location. ! let s:Tex_TempFileOrig_{s:Tex_NumTempFiles} = expand('%:p') ! let s:Tex_TempFileRange_{s:Tex_NumTempFiles} = a:firstline.','.a:lastline " Set up an autocmd to clean up the temp files when Vim exits. ! if Tex_GetVarValue('Tex_RemoveTempFiles') augroup RemoveTmpFiles au! *************** *** 457,466 **** " removed when Vim exits to avoid "file leakage". function! Tex_RemoveTempFiles() ! if !exists('g:Tex_NumTempFiles') || !g:Tex_RemoveTempFiles return endif let i = 1 ! while i <= g:Tex_NumTempFiles ! let tmpfile = g:Tex_TempFile_{i} " Remove the tmp file and all other associated files such as the " .log files etc. --- 441,450 ---- " removed when Vim exits to avoid "file leakage". function! Tex_RemoveTempFiles() ! if !exists('s:Tex_NumTempFiles') || !Tex_GetVarValue('Tex_RemoveTempFiles') return endif let i = 1 ! while i <= s:Tex_NumTempFiles ! let tmpfile = s:Tex_TempFile_{i} " Remove the tmp file and all other associated files such as the " .log files etc. *************** *** 485,490 **** " "rerun to get cross-references right" message from " the compiler output. ! let origlevel = g:Tex_IgnoreLevel ! let origpats = g:Tex_IgnoredWarnings let g:Tex_IgnoredWarnings = g:Tex_IgnoredWarnings."\n" --- 469,474 ---- " "rerun to get cross-references right" message from " the compiler output. ! let origlevel = Tex_GetVarValue('Tex_IgnoreLevel') ! let origpats = Tex_GetVarValue('Tex_IgnoredWarnings') let g:Tex_IgnoredWarnings = g:Tex_IgnoredWarnings."\n" *************** *** 541,546 **** let biblinesBefore = Tex_CatFile(bibFileName) ! echomsg "Running '".g:Tex_BibtexFlavor."' ..." ! let temp_mp = &mp | let &mp = g:Tex_BibtexFlavor exec 'silent! make '.mainFileName_root let &mp = temp_mp --- 525,530 ---- let biblinesBefore = Tex_CatFile(bibFileName) ! echomsg "Running '".Tex_GetVarValue('Tex_BibtexFlavor')."' ..." ! let temp_mp = &mp | let &mp = Tex_GetVarValue('Tex_BibtexFlavor') exec 'silent! make '.mainFileName_root let &mp = temp_mp |