Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv28289
Modified Files:
compiler.vim main.vim multicompile.vim packages.vim
templates.vim texmenuconf.vim texrc
Added Files:
pytools.py
Log Message:
A kind of big rearrangement of latex-suite is in order now that a stable
release (1.5) has been made.
main.vim, packages.vim, templates.vim
Change: Tex_FindInRtp() used some pattern substitution to convert from
files returned by globpath to the required format. This is
unreliable and _very_ platform dependent. Attempting to use
fnamemodify() instead which takes care of such issues internally.
This change fixed a couple of bugs on my windows machine.
multicompile.vim, main.vim
Change: Functions like Tex_CatFile() etc which originally were located in
multicompile.vim have been moved here. The python equivalents of
the functions have been placed in pytools.py. multicompile.vim is
now effectively "empty". In the future, this file might be removed
from CVS. For now, I have a single "finish" in the file. This is to
enable a problem-free transition when this file is finally removed.
pytools.py
New: This file contains certain python functions to work around limitations
in vim scripting language. For example, there is no way in vim to read
the contents of a file without opening a buffer on it.
main.vim
New: A function Tex_GetTempName() which returns the name of a termporary
file in a given directory. Ideally, when compiling a fragment of a
file, we should create the temporary file in the same directory as the
original file. This function enables this to be done. The temporary
files thus created are removed when vim exits.
texrc:
New: A new setting g:Tex_RemoveTempFiles which when set to 1 (default),
removes temporary files created during part compilation.
texmenuconf.vim, compiler.vim:
Change: Add the leading Tex_ prefix to certain functions in compiler.vim to
make things more consistent. There are still some functions without
the prefix. I will make those changes gradually.
--- NEW FILE: pytools.py ---
import string, vim, re, os, glob
# catFile: assigns a local variable retval to the contents of a file {{{
def catFile(filename):
try:
file = open(filename)
lines = ''.join(file.readlines())
file.close()
except:
lines = ''
# escape double quotes and backslashes before quoting the string so
# everything passes throught.
vim.command("""let retval = "%s" """ % re.sub(r'"|\\', r'\\\g<0>', lines))
return lines
# }}}
# isPresentInFile: check if regexp is present in the file {{{
def isPresentInFile(regexp, filename):
try:
fp = open(filename)
fcontents = string.join(fp.readlines(), '')
fp.close()
if re.search(regexp, fcontents):
vim.command('let retval = 1')
return 1
else:
vim.command('let retval = 0')
return None
except:
vim.command('let retval = 0')
return None
# }}}
# deleteFile: deletes a file if present {{{
# If the file does not exist, check if its a filepattern rather than a
# filename. If its a pattern, then deletes all files matching the
# pattern.
def deleteFile(filepattern):
if os.path.exists(filepattern):
try:
os.remove(filepattern)
except:
vim.command('let retval = -1')
else:
if glob.glob(filepattern):
for filename in glob.glob(filepattern):
os.remove(filename)
else:
vim.command('let retval = -1')
# }}}
# vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap
Index: compiler.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/compiler.vim,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** compiler.vim 9 Oct 2003 21:53:47 -0000 1.50
--- compiler.vim 7 Nov 2003 02:11:50 -0000 1.51
***************
*** 8,13 ****
"=============================================================================
! " SetTeXCompilerTarget: sets the 'target' for the next call to RunLaTeX() {{{
! function! SetTeXCompilerTarget(type, target)
if a:target == ''
if g:Tex_DefaultTargetFormat == 'dvi'
--- 8,13 ----
"=============================================================================
! " Tex_SetTeXCompilerTarget: sets the 'target' for the next call to Tex_RunLaTeX() {{{
! function! Tex_SetTeXCompilerTarget(type, target)
if a:target == ''
if g:Tex_DefaultTargetFormat == 'dvi'
***************
*** 77,86 ****
let target = 'dvi'
endif
! call SetTeXCompilerTarget('Compile', target)
! call SetTeXCompilerTarget('View', target)
endfunction
! com! -nargs=1 TCTarget :call SetTeXCompilerTarget('Compile', <f-args>)
! com! -nargs=1 TVTarget :call SetTeXCompilerTarget('View', <f-args>)
com! -nargs=? TTarget :call SetTeXTarget(<f-args>)
--- 77,86 ----
let target = 'dvi'
endif
! call Tex_SetTeXCompilerTarget('Compile', target)
! call Tex_SetTeXCompilerTarget('View', target)
endfunction
! com! -nargs=1 TCTarget :call Tex_SetTeXCompilerTarget('Compile', <f-args>)
! com! -nargs=1 TVTarget :call Tex_SetTeXCompilerTarget('View', <f-args>)
com! -nargs=? TTarget :call SetTeXTarget(<f-args>)
***************
*** 90,94 ****
function! Tex_CompileLatex()
if &ft != 'tex'
! echo "calling RunLaTeX from a non-tex file"
return
end
--- 90,94 ----
function! Tex_CompileLatex()
if &ft != 'tex'
! echo "calling Tex_RunLaTeX from a non-tex file"
return
end
***************
*** 106,110 ****
" else use current file
"
! " if mainfname exists, then it means it was supplied to RunLaTeX().
" Extract the complete file name including the extension.
let mainfname = Tex_GetMainFileName(':r')
--- 106,110 ----
" else use current file
"
! " if mainfname exists, then it means it was supplied to Tex_RunLaTeX().
" Extract the complete file name including the extension.
let mainfname = Tex_GetMainFileName(':r')
***************
*** 179,183 ****
endfunction " }}}
! " RunLaTeX: compilation function {{{
" this function runs the latex command on the currently open file. often times
" the file being currently edited is only a fragment being \input'ed into some
--- 179,183 ----
endfunction " }}}
! " Tex_RunLaTeX: compilation function {{{
" this function runs the latex command on the currently open file. often times
" the file being currently edited is only a fragment being \input'ed into some
***************
*** 188,194 ****
" main.tex.latexmain
" in the ~/thesis directory. this will then run "latex main.tex" when
! " RunLaTeX() is called.
! function! RunLaTeX()
! call Tex_Debug('getting to RunLaTeX, b:fragmentFile = '.exists('b:fragmentFile'), 'comp')
let dir = expand("%:p:h").'/'
--- 188,194 ----
" main.tex.latexmain
" in the ~/thesis directory. this will then run "latex main.tex" when
! " Tex_RunLaTeX() is called.
! function! Tex_RunLaTeX()
! call Tex_Debug('getting to Tex_RunLaTeX, b:fragmentFile = '.exists('b:fragmentFile'), 'comp')
let dir = expand("%:p:h").'/'
***************
*** 212,216 ****
while Tex_Strntok(dependency, ',', i) != ''
let s:target = Tex_Strntok(dependency, ',', i)
! call SetTeXCompilerTarget('Compile', s:target)
call Tex_Debug('setting target to '.s:target, 'comp')
--- 212,216 ----
while Tex_Strntok(dependency, ',', i) != ''
let s:target = Tex_Strntok(dependency, ',', i)
! call Tex_SetTeXCompilerTarget('Compile', s:target)
call Tex_Debug('setting target to '.s:target, 'comp')
***************
*** 236,249 ****
" }}}
! " ViewLaTeX: opens viewer {{{
" Description: opens the DVI viewer for the file being currently edited.
" Again, if the current file is a \input in a master file, see text above
! " RunLaTeX() to see how to set this information.
! " If ViewLaTeX was called with argument "part" show file which name is stored
" in g:tfile variable. If g:tfile doesnt exist, no problem. Function is called
" as silent.
! function! ViewLaTeX()
if &ft != 'tex'
! echo "calling ViewLaTeX from a non-tex file"
return
end
--- 236,249 ----
" }}}
! " Tex_ViewLaTeX: opens viewer {{{
" Description: opens the DVI viewer for the file being currently edited.
" Again, if the current file is a \input in a master file, see text above
! " Tex_RunLaTeX() to see how to set this information.
! " If Tex_ViewLaTeX was called with argument "part" show file which name is stored
" in g:tfile variable. If g:tfile doesnt exist, no problem. Function is called
" as silent.
! function! Tex_ViewLaTeX()
if &ft != 'tex'
! echo "calling Tex_ViewLaTeX from a non-tex file"
return
end
***************
*** 304,308 ****
" Tex_ForwardSearchLaTeX: searches for current location in dvi file. {{{
" Description: if the DVI viewr is compatible, then take the viewer to that
! " position in the dvi file. see docs for RunLaTeX() to set a
" master file if this is an \input'ed file.
" Tip: With YAP on Windows, it is possible to do forward and inverse searches
--- 304,308 ----
" Tex_ForwardSearchLaTeX: searches for current location in dvi file. {{{
" Description: if the DVI viewr is compatible, then take the viewer to that
! " position in the dvi file. see docs for Tex_RunLaTeX() to set a
" master file if this is an \input'ed file.
" Tip: With YAP on Windows, it is possible to do forward and inverse searches
***************
*** 315,319 ****
function! Tex_ForwardSearchLaTeX()
if &ft != 'tex'
! echo "calling ViewLaTeX from a non-tex file"
return
end
--- 315,319 ----
function! Tex_ForwardSearchLaTeX()
if &ft != 'tex'
! echo "calling Tex_ViewLaTeX from a non-tex file"
return
end
***************
*** 359,375 ****
" }}}
" Tex_PartCompile: compiles selected fragment {{{
" Description: creates a temporary file from the selected fragment of text
! " prepending the preamble and \end{document} and then asks RunLaTeX() to
" compile it.
function! Tex_PartCompile() range
-
call Tex_Debug('getting to Tex_PartCompile', 'comp')
" Save position
let pos = line('.').' | normal! '.virtcol('.').'|'
! " Create temporary file and save its name into global variable to use in
! " compiler.vim
! let tmpfile = tempname().'.tex'
" If mainfile exists open it in tiny window and extract preamble there,
--- 359,398 ----
" }}}
+
+ " ==============================================================================
+ " Functions for compiling parts of a file.
+ " ==============================================================================
" Tex_PartCompile: compiles selected fragment {{{
" Description: creates a temporary file from the selected fragment of text
! " prepending the preamble and \end{document} and then asks Tex_RunLaTeX() to
" compile it.
function! Tex_PartCompile() range
call Tex_Debug('getting to 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
! " names in the fragment.
! let tmpfile = Tex_GetTempName(expand('%:p:h'))
!
! " 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!
! au VimLeave * :call Tex_RemoveTempFiles()
! augroup END
! endif
" If mainfile exists open it in tiny window and extract preamble there,
***************
*** 396,400 ****
let b:fragmentFile = 1
! silent! call RunLaTeX()
endfunction " }}}
--- 419,544 ----
let b:fragmentFile = 1
! silent! call Tex_RunLaTeX()
! endfunction " }}}
! " Tex_RemoveTempFiles: cleans up temporary files created during part compilation {{{
! " Description: During part compilation, temporary files containing the
! " visually selected text are created. These files need to be
! " 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.
! call Tex_DeleteFile(fnamemodify(tmpfile, ':p:r').'.*')
! let i = i + 1
! endwhile
! endfunction " }}}
!
! " ==============================================================================
! " Compiling a file multiple times to resolve references/citations etc.
! " ==============================================================================
! " Tex_CompileMultipleTimes: The main function {{{
! " Description: compiles a file multiple times to get cross-references right.
! function! Tex_CompileMultipleTimes()
! let mainFileName_root = Tex_GetMainFileName(':p:t:r:r')
!
! if mainFileName_root == ''
! let mainFileName_root = expand("%:p:t:r")
! endif
!
! " First ignore undefined references and the
! " "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"
! \ . 'Reference %.%# undefined'."\n"
! \ . 'Rerun to get cross-references right'
! TCLevel 1000
!
! let idxFileName = mainFileName_root.'.idx'
!
! let runCount = 0
! let needToRerun = 1
! while needToRerun == 1 && runCount < 5
! " assume we need to run only once.
! let needToRerun = 0
!
! let idxlinesBefore = Tex_CatFile(idxFileName)
!
! " first run latex.
! echomsg "latex run number : ".(runCount+1)
! silent! call Tex_CompileLatex()
!
! " If there are errors in any latex compilation step, immediately
! " return. For now, do not bother with warnings because those might go
! " away after compiling again or after bibtex is run etc.
! let errlist = Tex_GetErrorList()
! call Tex_Debug("errors = [".errlist."]", "err")
!
! if errlist =~ '\d\+\s\f\+:\d\+\serror'
! let g:Tex_IgnoredWarnings = origpats
! exec 'TCLevel '.origlevel
!
! return
! endif
!
! let idxlinesAfter = Tex_CatFile(idxFileName)
!
! " If .idx file changed, then run makeindex to generate the new .ind
! " file and remember to rerun latex.
! if runCount == 0 && glob(idxFileName) != '' && idxlinesBefore != idxlinesAfter
! echomsg "Running makeindex..."
! let temp_mp = &mp | let &mp='makeindex $*.idx'
! exec 'silent! make '.mainFileName_root
! let &mp = temp_mp
!
! let needToRerun = 1
! endif
!
! " The first time we see if we need to run bibtex and if the .bbl file
! " changes, we will rerun latex.
! if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux')
! let bibFileName = mainFileName_root . '.bbl'
!
! 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
!
! let biblinesAfter = Tex_CatFile(bibFileName)
!
! " If the .bbl file changed after running bibtex, we need to
! " latex again.
! if biblinesAfter != biblinesBefore
! echomsg 'Need to rerun because bibliography file changed...'
! let needToRerun = 1
! endif
! endif
!
! " check if latex asks us to rerun
! if Tex_IsPresentInFile('Rerun to get cross-references right', mainFileName_root.'.log')
! echomsg "Need to rerun to get cross-references right..."
! let needToRerun = 1
! endif
!
! let runCount = runCount + 1
! endwhile
!
! echomsg "Ran latex ".runCount." time(s)"
!
! let g:Tex_IgnoredWarnings = origpats
! exec 'TCLevel '.origlevel
! " After all compiler calls are done, reparse the .log file for
! " errors/warnings to handle the situation where the clist might have been
! " emptied because of bibtex/makeindex being run as the last step.
! exec 'silent! cfile '.mainFileName_root.'.log'
endfunction " }}}
***************
*** 577,585 ****
return
endif
! nnoremap <buffer> <Leader>ll :call RunLaTeX()<cr>
vnoremap <buffer> <Leader>ll :call Tex_PartCompile()<cr>
! nnoremap <buffer> <Leader>lv :call ViewLaTeX()<cr>
nnoremap <buffer> <Leader>ls :call Tex_ForwardSearchLaTeX()<cr>
- endif
endfunction
--- 721,728 ----
return
endif
! nnoremap <buffer> <Leader>ll :call Tex_RunLaTeX()<cr>
vnoremap <buffer> <Leader>ll :call Tex_PartCompile()<cr>
! nnoremap <buffer> <Leader>lv :call Tex_ViewLaTeX()<cr>
nnoremap <buffer> <Leader>ls :call Tex_ForwardSearchLaTeX()<cr>
endfunction
***************
*** 593,596 ****
--- 736,743 ----
command! -nargs=0 -range=% TPartCompile :<line1>, <line2> silent! call Tex_PartCompile()
+ " Setting b:fragmentFile = 1 makes Tex_CompileLatex consider the present file
+ " the _main_ file irrespective of the presence of a .latexmain file.
+ command! -nargs=0 TCompileThis let b:fragmentFile = 1
+ command! -nargs=0 TCompileMainFile let b:fragmentFile = 0
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
Index: main.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/main.vim,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** main.vim 30 Oct 2003 22:49:13 -0000 1.52
--- main.vim 7 Nov 2003 02:11:50 -0000 1.53
***************
*** 555,559 ****
endif
let s:debugString_{pattern} = s:debugString_{pattern}.a:str."\n"
! let s:debugString_ = s:debugString_.pattern.' : '.a:str."\n"
endfunction " }}}
" Tex_PrintDebug: prings s:debugString {{{
--- 555,561 ----
endif
let s:debugString_{pattern} = s:debugString_{pattern}.a:str."\n"
!
! let s:debugString_ = (exists('s:debugString_') ? s:debugString_ : '')
! \ . a:str."\n"
endfunction " }}}
" Tex_PrintDebug: prings s:debugString {{{
***************
*** 587,634 ****
" Description: Checks if file exists in globpath(&rtp, ...) and cuts off the
" rest of returned names. This guarantees that sourced file is
! " from $HOME. Drawback: doesn't respect special after directory.
! " If first argument == '' return list of files separated with \n
! function! Tex_FindInRtp(filename, directory)
! " We need different behavior for each special subdirectory:
! if a:directory == 'packages'
! if a:filename != ''
! let filepath = globpath(&rtp, "ftplugin/latex-suite/packages/".a:filename)
! "if filepath != '' && filepath =~ '\n'
! "let filepath = substitute(filepath, '\n.*', '', '')
! "endif
! return filepath
! else
! " Return list of packages separated with ,
! let list = globpath(&rtp, "ftplugin/latex-suite/packages/*")
! let list = substitute(list,'\n',',','g')
! let list = substitute(list,'^\|,[^,]*/',',','g')
! return list
! endif
! elseif a:directory == 'dictionaries'
! if a:filename != ''
! " Return list of dictionaries separated with ,
! let filepath = globpath(&rtp, "ftplugin/latex-suite/dictionaries/".a:filename)
! let filepath = substitute(filepath, '\n', ',', 'g')
! return filepath
endif
! elseif a:directory =~ 'macros\|templates'
! if a:filename != ''
! " Return first file extracted from &rtp
! let filepath = globpath(&rtp, "ftplugin/latex-suite/".a:directory."/".a:filename)
! if filepath != '' && filepath =~ '\n'
! let filepath = substitute(filepath, '\n.*', '', '')
! endif
! return filepath
! else
! " Return list of macros/templates separated with ,
! let list = globpath(&rtp, "ftplugin/latex-suite/".a:directory."/*")
! let list = substitute(list,'\.tex', '', 'ge')
! let list = substitute(list,'^\|\n',',','g')
! let list = substitute(list,',[^,]*/',',','g')
! let list = substitute(list,'^,', '', '')
! return list
endif
! endif
endfunction
--- 589,641 ----
" Description: Checks if file exists in globpath(&rtp, ...) and cuts off the
" rest of returned names. This guarantees that sourced file is
! " from $HOME.
! " If an optional argument is given, it specifies how to expand
! " each filename found. For example, '%:p' will return a list of
! " the complete paths to the files. By default returns trailing
! " path-names without extenions.
! " NOTE: This function is very slow when a large number of
! " matches are found because of a while loop which modifies
! " each filename found. Some speedup was acheived by using
! " a tokenizer approach rather than using Tex_Strntok which
! " would have been more obvious.
! function! Tex_FindInRtp(filename, directory, ...)
! " how to expand each filename. ':p:t:r' modifies each filename to its
! " trailing part without extension.
! let expand = (a:0 > 0 ? a:1 : ':p:t:r')
! " The pattern used... An empty filename should be regarded as '*'
! let pattern = (a:filename != '' ? a:filename : '*')
!
! let filelist = globpath(&rtp, 'ftplugin/latex-suite/'.a:directory.'/'.pattern)."\n"
! call Tex_Debug("filelist = ".filelist, "main")
! if filelist == ''
! return ''
! endif
!
! if a:filename != ''
! return fnamemodify(Tex_Strntok(filelist, "\n", 1), expand)
! endif
!
! " Now cycle through the files modifying each filename in the desired
! " manner.
! let retfilelist = ''
! let i = 1
! while 1
! " Extract the portion till the next newline. Then shorten the filelist
! " by removing till the newline.
! let nextnewline = stridx(filelist, "\n")
! if nextnewline == -1
! break
endif
! let filename = strpart(filelist, 0, nextnewline)
! let filelist = strpart(filelist, nextnewline+1)
!
! " The actual modification.
! if fnamemodify(filename, expand) != ''
! let retfilelist = retfilelist.fnamemodify(filename, expand).","
endif
! let i = i + 1
! endwhile
+ return substitute(retfilelist, ',$', '', '')
endfunction
***************
*** 645,648 ****
--- 652,673 ----
return errlist
endfunction " }}}
+ " Tex_GetTempName: get the name of a temporary file in specified directory {{{
+ " Description: Unlike vim's native tempname(), this function returns the name
+ " of a temporary file in the directory specified. This enables
+ " us to create temporary files in a specified directory.
+ function! Tex_GetTempName(dirname)
+ let prefix = 'latexSuiteTemp'
+ let slash = (a:dirname =~ '\\\|/$' ? '' : '/')
+ let i = 0
+ while filereadable(a:dirname.slash.prefix.i.'.tex') && i < 1000
+ let i = i + 1
+ endwhile
+ if filereadable(a:dirname.slash.prefix.i.'.tex')
+ echoerr "Temporary file could not be created in ".a:dirname
+ return ''
+ endif
+ return expand(a:dirname.slash.prefix.i.'.tex', ':p')
+ endfunction
+ " }}}
" source texproject.vim before other files
***************
*** 754,761 ****
" Mappings defined in package files will overwrite all other
-
exe 'source '.s:path.'/packages.vim'
let &cpo = s:save_cpo
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap
--- 779,893 ----
" Mappings defined in package files will overwrite all other
exe 'source '.s:path.'/packages.vim'
+ " ==============================================================================
+ " These functions are used to immitate certain operating system type functions
+ " (like reading the contents of a file), which are not available in vim. For
+ " example, in Vim, its not possible to read the contents of a file without
+ " opening a buffer on it, which means that over time, lots of buffers can open
+ " up needlessly.
+ "
+ " If python is available (and allowed), then these functions utilize python
+ " library functions without making calls to external programs.
+ " ==============================================================================
+ " Tex_GotoTempFile: open a temp file. reuse from next time on {{{
+ function! Tex_GotoTempFile()
+ if !exists('s:tempFileName')
+ let s:tempFileName = tempname()
+ endif
+ exec 'silent! split '.s:tempFileName
+ endfunction " }}}
+ " Tex_IsPresentInFile: finds if a string str, is present in filename {{{
+ if has('python') && g:Tex_UsePython
+ function! Tex_IsPresentInFile(regexp, filename)
+ exec 'python isPresentInFile(r"'.a:regexp.'", r"'.a:filename.'")'
+
+ return retval
+ endfunction
+ else
+ function! Tex_IsPresentInFile(regexp, filename)
+ call Tex_GotoTempFile()
+
+ silent! 1,$ d _
+ let _report = &report
+ let _sc = &sc
+ set report=9999999 nosc
+ exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
+ set nomod
+ let &report = _report
+ let &sc = _sc
+
+ if search(a:regexp, 'w')
+ let retval = 1
+ else
+ let retval = 0
+ endif
+ silent! bd
+ return retval
+ endfunction
+ endif " }}}
+ " Tex_CatFile: returns the contents of a file in a <NL> seperated string {{{
+ if has('python') && g:Tex_UsePython
+ function! Tex_CatFile(filename)
+ " catFile assigns a value to retval
+ exec 'python catFile("'.a:filename.'")'
+
+ return retval
+ endfunction
+ else
+ function! Tex_CatFile(filename)
+ if glob(a:filename) == ''
+ return ''
+ endif
+
+ call Tex_GotoTempFile()
+
+ silent! 1,$ d _
+
+ let _report = &report
+ let _sc = &sc
+ set report=9999999 nosc
+ exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
+
+ set nomod
+ let _a = @a
+ silent! normal! ggVG"ay
+ let retval = @a
+ let @a = _a
+
+ silent! bd
+ let &report = _report
+ let &sc = _sc
+ return retval
+ endfunction
+ endif
+ " }}}
+ " Tex_DeleteFile: removes a file if present {{{
+ " Description:
+ if has('python') && g:Tex_UsePython
+ function! Tex_DeleteFile(filename)
+ exec 'python deleteFile(r"'.a:filename.'")'
+
+ if exists('retval')
+ return retval
+ endif
+ endfunction
+ else
+ function! Tex_DeleteFile(filename)
+ if filereadable(a:filename)
+ exec '! '.g:Tex_RmCmd.' '.a:filename
+ endif
+ endfunction
+ endif
+ " }}}
+
let &cpo = s:save_cpo
+
+ " Define the functions in python if available.
+ if !has('python') || !g:Tex_UsePython
+ finish
+ endif
+
+ exec 'pyfile '.expand('<sfile>:p:h').'/pytools.py'
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap
Index: multicompile.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/multicompile.vim,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** multicompile.vim 9 Oct 2003 21:53:47 -0000 1.9
--- multicompile.vim 7 Nov 2003 02:11:50 -0000 1.10
***************
*** 10,231 ****
" ============================================================================
! " Tex_CompileMultipleTimes: The main function {{{
! " Description: compiles a file multiple times to get cross-references right.
! function! Tex_CompileMultipleTimes()
! let mainFileName_root = Tex_GetMainFileName(':p:t:r:r')
!
! if mainFileName_root == ''
! let mainFileName_root = expand("%:p:t:r")
! endif
!
! " First ignore undefined references and the
! " "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"
! \ . 'Reference %.%# undefined'."\n"
! \ . 'Rerun to get cross-references right'
! TCLevel 1000
!
! let idxFileName = mainFileName_root.'.idx'
!
! let runCount = 0
! let needToRerun = 1
! while needToRerun == 1 && runCount < 5
! " assume we need to run only once.
! let needToRerun = 0
!
! let idxlinesBefore = Tex_CatFile(idxFileName)
!
! " first run latex.
! echomsg "latex run number : ".(runCount+1)
! silent! call Tex_CompileLatex()
!
! " If there are errors in any latex compilation step, immediately
! " return. For now, do not bother with warnings because those might go
! " away after compiling again or after bibtex is run etc.
! let errlist = Tex_GetErrorList()
! call Tex_Debug("errors = [".errlist."]", "err")
!
! if errlist =~ '\d\+\s\f\+:\d\+\serror'
! let g:Tex_IgnoredWarnings = origpats
! exec 'TCLevel '.origlevel
!
! return
! endif
!
! let idxlinesAfter = Tex_CatFile(idxFileName)
!
! " If .idx file changed, then run makeindex to generate the new .ind
! " file and remember to rerun latex.
! if runCount == 0 && glob(idxFileName) != '' && idxlinesBefore != idxlinesAfter
! echomsg "Running makeindex..."
! let temp_mp = &mp | let &mp='makeindex $*.idx'
! exec 'silent! make '.mainFileName_root
! let &mp = temp_mp
!
! let needToRerun = 1
! endif
!
! " The first time we see if we need to run bibtex and if the .bbl file
! " changes, we will rerun latex.
! if runCount == 0 && Tex_IsPresentInFile('\\bibdata', mainFileName_root.'.aux')
! let bibFileName = mainFileName_root . '.bbl'
!
! 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
!
! let biblinesAfter = Tex_CatFile(bibFileName)
!
! " If the .bbl file changed after running bibtex, we need to
! " latex again.
! if biblinesAfter != biblinesBefore
! echomsg 'Need to rerun because bibliography file changed...'
! let needToRerun = 1
! endif
! endif
!
! " check if latex asks us to rerun
! if Tex_IsPresentInFile('Rerun to get cross-references right', mainFileName_root.'.log')
! echomsg "Need to rerun to get cross-references right..."
! let needToRerun = 1
! endif
!
! let runCount = runCount + 1
! endwhile
!
! echomsg "Ran latex ".runCount." time(s)"
!
! let g:Tex_IgnoredWarnings = origpats
! exec 'TCLevel '.origlevel
! " After all compiler calls are done, reparse the .log file for
! " errors/warnings to handle the situation where the clist might have been
! " emptied because of bibtex/makeindex being run as the last step.
! exec 'silent! cfile '.mainFileName_root.'.log'
! endfunction " }}}
!
! " Various helper functions used by Tex_CompileMultipleTimes(). These functions
! " use python where available (and allowed) otherwise do it in native vim at
! " the cost of some slowdown and a new temporary buffer being added to the
! " buffer list.
! " Tex_GotoTempFile: open a temp file. reuse from next time on {{{
! function! Tex_GotoTempFile()
! if !exists('s:tempFileName')
! let s:tempFileName = tempname()
! endif
! exec 'silent! split '.s:tempFileName
! endfunction " }}}
! " Tex_IsPresentInFile: finds if a string str, is present in filename {{{
! if has('python') && g:Tex_UsePython
! function! Tex_IsPresentInFile(regexp, filename)
! exec 'python isPresentInFile(r"'.a:regexp.'", r"'.a:filename.'")'
!
! return retval
! endfunction
! else
! function! Tex_IsPresentInFile(regexp, filename)
! call Tex_GotoTempFile()
!
! silent! 1,$ d _
! let _report = &report
! let _sc = &sc
! set report=9999999 nosc
! exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
! set nomod
! let &report = _report
! let &sc = _sc
!
! if search(a:regexp, 'w')
! let retval = 1
! else
! let retval = 0
! endif
! silent! bd
! return retval
! endfunction
! endif " }}}
! " Tex_CatFile: returns the contents of a file in a <NL> seperated string {{{
! if has('python') && g:Tex_UsePython
! function! Tex_CatFile(filename)
! " catFile assigns a value to retval
! exec 'python catFile("'.a:filename.'")'
!
! return retval
! endfunction
! else
! function! Tex_CatFile(filename)
! if glob(a:filename) == ''
! return ''
! endif
!
! call Tex_GotoTempFile()
!
! silent! 1,$ d _
!
! let _report = &report
! let _sc = &sc
! set report=9999999 nosc
! exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename
!
! set nomod
! let _a = @a
! silent! normal! ggVG"ay
! let retval = @a
! let @a = _a
!
! silent! bd
! let &report = _report
! let &sc = _sc
! return retval
! endfunction
! endif
! " }}}
!
! " Define the functions in python if available.
! if !has('python') || !g:Tex_UsePython
! finish
! endif
!
! python <<EOF
! import string, vim, re
! # catFile: assigns a local variable retval to the contents of a file {{{
! def catFile(filename):
! try:
! file = open(filename)
! lines = ''.join(file.readlines())
! file.close()
! except:
! lines = ''
!
! # escape double quotes and backslashes before quoting the string so
! # everything passes throught.
! vim.command("""let retval = "%s" """ % re.sub(r'"|\\', r'\\\g<0>', lines))
! return lines
!
! # }}}
! # isPresentInFile: check if regexp is present in the file {{{
! def isPresentInFile(regexp, filename):
! try:
! fp = open(filename)
! fcontents = string.join(fp.readlines(), '')
! fp.close()
! if re.search(regexp, fcontents):
! vim.command('let retval = 1')
! return 1
! else:
! vim.command('let retval = 0')
! return None
! except:
! vim.command('let retval = 0')
! return None
- # }}}
- EOF
" vim:fdm=marker:nowrap:noet:ff=unix:ts=4:sw=4
--- 10,17 ----
" ============================================================================
! " The contents of this file have been moved to compiler.vim, the file which
! " contains all functions relevant to compiling and viewing.
! finish
" vim:fdm=marker:nowrap:noet:ff=unix:ts=4:sw=4
Index: packages.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/packages.vim,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** packages.vim 29 Sep 2003 02:23:49 -0000 1.41
--- packages.vim 7 Nov 2003 02:11:50 -0000 1.42
***************
*** 75,79 ****
endif
" Return full list of dictionaries (separated with ,) for package in &rtp
! let dictname = Tex_FindInRtp(a:package, 'dictionaries')
if dictname != ''
exe 'setlocal dict+=' . dictname
--- 75,79 ----
endif
" Return full list of dictionaries (separated with ,) for package in &rtp
! let dictname = Tex_FindInRtp(a:package, 'dictionaries', ':p')
if dictname != ''
exe 'setlocal dict+=' . dictname
***************
*** 459,468 ****
" of 20...
function! Tex_pack_supp_menu()
!
! " Get list of packages in all rtp directories.
! " TODO: sort it and get rid of duplicate entries.
! let suplist = globpath(&rtp, "ftplugin/latex-suite/packages/*")
! let suplist = substitute(suplist,'\n',',','g')
! let suplist = substitute(suplist,'^\|,[^,]*/',',','g').","
call Tex_MakeSubmenu(suplist, g:Tex_PackagesMenuLocation.'Supported.',
--- 459,464 ----
" of 20...
function! Tex_pack_supp_menu()
! let suplist = Tex_FindInRtp('', 'packages')
! call Tex_Debug("suplist = [".suplist.']', "pack")
call Tex_MakeSubmenu(suplist, g:Tex_PackagesMenuLocation.'Supported.',
Index: templates.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/templates.vim,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** templates.vim 29 Sep 2003 02:23:49 -0000 1.13
--- templates.vim 7 Nov 2003 02:11:50 -0000 1.14
***************
*** 49,53 ****
endif
! let fname = Tex_FindInRtp(filename, 'templates')
silent! exe "0read ".fname
" The first line of the file contains the specifications of what the
--- 49,54 ----
endif
! let fname = Tex_FindInRtp(filename.'.tex', 'templates', ':p')
! call Tex_Debug("0read ".fname, 'templates')
silent! exe "0read ".fname
" The first line of the file contains the specifications of what the
***************
*** 60,64 ****
let s:comTemp = substitute(getline(1), pattern, '\4', '')
! call Tex_Debug('phs = '.s:phsTemp.', phe = '.s:pheTemp.', exe = '.s:exeTemp.', com = '.s:comTemp)
" delete the first line into ze blackhole.
--- 61,65 ----
let s:comTemp = substitute(getline(1), pattern, '\4', '')
! call Tex_Debug('phs = '.s:phsTemp.', phe = '.s:pheTemp.', exe = '.s:exeTemp.', com = '.s:comTemp, 'templates')
" delete the first line into ze blackhole.
Index: texmenuconf.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/texmenuconf.vim,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** texmenuconf.vim 29 Aug 2003 01:37:02 -0000 1.20
--- texmenuconf.vim 7 Nov 2003 02:11:50 -0000 1.21
***************
*** 56,62 ****
" menus for compiling / viewing etc.
exec 'anoremenu '.g:Tex_MainMenuLocation.'.30 '.s:mainmenuname.'&Compile<tab>'.s:mapleader.'ll'.
! \' :silent! call RunLaTeX()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.40 '.s:mainmenuname.'&View<tab>'.s:mapleader.'lv'.
! \' :silent! call ViewLaTeX()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.50 '.s:mainmenuname.'&Search<tab>'.s:mapleader.'ls'.
\' :silent! call ForwardSearchLaTeX()<CR>'
--- 56,62 ----
" menus for compiling / viewing etc.
exec 'anoremenu '.g:Tex_MainMenuLocation.'.30 '.s:mainmenuname.'&Compile<tab>'.s:mapleader.'ll'.
! \' :silent! call Tex_RunLaTeX()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.40 '.s:mainmenuname.'&View<tab>'.s:mapleader.'lv'.
! \' :silent! call Tex_ViewLaTeX()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.50 '.s:mainmenuname.'&Search<tab>'.s:mapleader.'ls'.
\' :silent! call ForwardSearchLaTeX()<CR>'
***************
*** 64,70 ****
\' :call SetTeXTarget()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.70 '.s:mainmenuname.'&Compiler\ Target<tab>:TCTarget'.
! \' :call SetTeXCompilerTarget("Compile", "")<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.80 '.s:mainmenuname.'&Viewer\ Target<tab>:TVTarget'.
! \' :call SetTeXCompilerTarget("View", "")<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.90 '.s:mainmenuname.'Set\ &Ignore\ Level<tab>:TCLevel'.
\' :TCLevel<CR>'
--- 64,70 ----
\' :call SetTeXTarget()<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.70 '.s:mainmenuname.'&Compiler\ Target<tab>:TCTarget'.
! \' :call Tex_SetTeXCompilerTarget("Compile", "")<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.80 '.s:mainmenuname.'&Viewer\ Target<tab>:TVTarget'.
! \' :call Tex_SetTeXCompilerTarget("View", "")<CR>'
exec 'anoremenu '.g:Tex_MainMenuLocation.'.90 '.s:mainmenuname.'Set\ &Ignore\ Level<tab>:TCLevel'.
\' :TCLevel<CR>'
Index: texrc
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/texrc,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** texrc 3 Oct 2003 10:35:28 -0000 1.40
--- texrc 7 Nov 2003 02:11:50 -0000 1.41
***************
*** 65,72 ****
--- 65,75 ----
if &shell =~ 'sh'
TexLet g:Tex_CatCmd = 'cat'
+ TexLet g:Tex_RmCmd = 'rm'
else
TexLet g:Tex_CatCmd = 'type'
+ TexLet g:Tex_RmCmd = 'del'
endif
+
" }}}
" ==============================================================================
***************
*** 195,198 ****
--- 198,204 ----
" errors after compilation
TexLet g:Tex_GotoError = 1
+
+ " Remove temp files created during part compilations when vim exits.
+ TexLet g:Tex_RemoveTempFiles = 1
" }}}
|