[Vim-latex-cvs] vimfiles/ftplugin/latex-suite texviewer.vim,1.3,1.4
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2004-05-16 17:38:52
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15503 Modified Files: texviewer.vim Log Message: New: Instead of searching for \\label's in all the .tex files in the present directory, only search in the mainfile and all the included files. Index: texviewer.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/texviewer.vim,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** texviewer.vim 9 May 2004 22:43:00 -0000 1.3 --- texviewer.vim 16 May 2004 17:38:41 -0000 1.4 *************** *** 63,67 **** " Thus " s:curline = '\psfig[option=value]{figure=' ! " (with possibly some junk before \includegraphics) " from which we need to extract " s:type = 'psfig' --- 63,67 ---- " Thus " s:curline = '\psfig[option=value]{figure=' ! " (with possibly some junk before \psfig) " from which we need to extract " s:type = 'psfig' *************** *** 76,80 **** if exists("s:type") && s:type =~ 'ref' call Tex_Debug("silent! grep! ".Tex_EscapeForGrep('\\label{'.s:prefix)." *.tex", 'view') ! exec "silent! grep! ".Tex_EscapeForGrep('\\label{'.s:prefix)." *.tex" redraw! call <SID>Tex_SetupCWindow() --- 76,81 ---- if exists("s:type") && s:type =~ 'ref' call Tex_Debug("silent! grep! ".Tex_EscapeForGrep('\\label{'.s:prefix)." *.tex", 'view') ! silent! grep! ____HIGHLY_IMPROBABLE___ % ! call Tex_GrepHelper(s:prefix, 'label') redraw! call <SID>Tex_SetupCWindow() *************** *** 91,96 **** call <SID>Tex_SetupCWindow(s:citeSearchHistory) else ! call Tex_Debug('calling Tex_GrepForBibItems', 'view') ! call Tex_GrepForBibItems(s:prefix) redraw! call <SID>Tex_SetupCWindow() --- 92,97 ---- call <SID>Tex_SetupCWindow(s:citeSearchHistory) else ! call Tex_Debug('calling Tex_GrepHelper', 'view') ! call Tex_GrepHelper(s:prefix, 'bib') redraw! call <SID>Tex_SetupCWindow() *************** *** 258,262 **** " ============================================================================== ! " Ref/Cite completion helper functions " ============================================================================== " Tex_SetupCWindow: set maps and local settings for cwindow {{{ --- 259,263 ---- " ============================================================================== ! " Helper functions for dealing with the 'quickfix' and 'preview' windows. " ============================================================================== " Tex_SetupCWindow: set maps and local settings for cwindow {{{ *************** *** 427,431 **** exe s:pos endfunction " }}} - " Tex_GoToLocation: Go to chosen location {{{ " Description: Get number of current line and go to this number --- 428,431 ---- *************** *** 446,481 **** " ============================================================================== ! " Bibliography specific functions " ============================================================================== ! " Tex_GrepForBibItems: grep main filename for bib items {{{ " Description: ! function! Tex_GrepForBibItems(prefix) ! let mainfname = Tex_GetMainFileName(':p') ! ! let toquit = 0 ! if bufnr('%') != bufnr(mainfname) ! exec 'split '.mainfname ! let toquit = 1 ! endif ! let _path = &path let _suffixesadd = &suffixesadd ! let &path = '.,'.g:Tex_BIBINPUTS ! let &suffixesadd = '.tex' let pos = line('.').'| normal! '.virtcol('.').'|' ! let foundCiteFile = Tex_ScanFileForCite(a:prefix) exec pos let &path = _path let &suffixesadd = _suffixesadd - if foundCiteFile - if toquit - q - endif - return - endif endfunction " }}} " Tex_ScanFileForCite: search for \bibitem's in .bib or .bbl or tex files {{{ --- 446,482 ---- " ============================================================================== ! " Functions for finding \\label's or \\bibitem's in the main file. " ============================================================================== ! " Tex_GrepHelper: grep main filename for \\bibitem's or \\label's {{{ " Description: ! function! Tex_GrepHelper(prefix, what) let _path = &path let _suffixesadd = &suffixesadd + let _hidden = &hidden ! let mainfname = Tex_GetMainFileName(':p') ! " If we are already editing the file, then use :split without any ! " arguments so it works even if the file is modified. ! " FIXME: If mainfname is being presently edited in another window and ! " is 'modified', then the second split statement will not work. ! " We will need to travel to that window and back. ! if mainfname == expand('%:p') ! split ! else ! exec 'split '.mainfname ! endif let pos = line('.').'| normal! '.virtcol('.').'|' ! if a:what =~ 'bib' ! call Tex_ScanFileForCite(a:prefix) ! else ! call Tex_ScanFileForLabels(a:prefix) ! endif exec pos + q let &path = _path let &suffixesadd = _suffixesadd endfunction " }}} " Tex_ScanFileForCite: search for \bibitem's in .bib or .bbl or tex files {{{ *************** *** 497,501 **** " as soon as the first \bibliography or \begin{thebibliography} is found. function! Tex_ScanFileForCite(prefix) ! call Tex_Debug('searching for bibkeys in '.bufname('%').' (buffer #'.bufnr('%').')', 'view') let presBufNum = bufnr('%') --- 498,502 ---- " as soon as the first \bibliography or \begin{thebibliography} is found. function! Tex_ScanFileForCite(prefix) ! call Tex_Debug('+Tex_ScanFileForCite: searching for bibkeys in '.bufname('%').' (buffer #'.bufnr('%').')', 'view') let presBufNum = bufnr('%') *************** *** 505,509 **** " bibliography. if search('\\bibliography{', 'w') ! call Tex_Debug('found bibliography command in '.bufname('%'), 'view') " convey that we have found a bibliography command. we do not need to " proceed any further. --- 506,510 ---- " bibliography. if search('\\bibliography{', 'w') ! call Tex_Debug('Tex_ScanFileForCite: found bibliography command in '.bufname('%'), 'view') " convey that we have found a bibliography command. we do not need to " proceed any further. *************** *** 516,519 **** --- 517,522 ---- call Tex_Debug('trying to search through ['.bibnames.']', 'view') + let &path = '.,'.g:Tex_BIBINPUTS + let i = 1 while Tex_Strntok(bibnames, ',', i) != '' *************** *** 533,537 **** lcd %:p:h " use the appropriate syntax for the .bib file. ! exec "silent! grepadd ".Tex_EscapeForGrep('@.*{'.a:prefix)." %" else let thisbufnum = bufnr('%') --- 536,540 ---- lcd %:p:h " use the appropriate syntax for the .bib file. ! exec "silent! grepadd! ".Tex_EscapeForGrep('@.*{'.a:prefix)." %" else let thisbufnum = bufnr('%') *************** *** 541,545 **** call Tex_Debug('finding .bbl file ['.bufname('.').']', 'view') lcd %:p:h ! exec "silent! grepadd ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %" endif endif --- 544,548 ---- call Tex_Debug('finding .bbl file ['.bufname('.').']', 'view') lcd %:p:h ! exec "silent! grepadd! ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %" endif endif *************** *** 550,553 **** --- 553,558 ---- endwhile + let &path = _path + if foundCiteFile return 1 *************** *** 565,570 **** split lcd %:p:h ! call Tex_Debug("silent! grepadd ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %", 'view') ! exec "silent! grepadd ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %" q --- 570,575 ---- split lcd %:p:h ! call Tex_Debug("silent! grepadd! ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %", 'view') ! exec "silent! grepadd! ".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %" q *************** *** 575,578 **** --- 580,586 ---- " in this file, search for these environments in all the files which this " file includes. + let &path = '.,'.g:Tex_TEXINPUTS + let &suffixesadd = '.tex' + exec 0 let wrap = 'w' *************** *** 598,606 **** endwhile return 0 endfunction " }}} " ============================================================================== ! " Custom Completion help functions/settings " ============================================================================== " Tex_completion_{var}: similar variables can be set in package files {{{ --- 606,653 ---- endwhile + return 0 endfunction " }}} + " Tex_ScanFileForLabels: greps present file and included files for \\label's {{{ + " Description: + " Grep the presently edited file for \\label's. If the present file \include's + " or \input's other files, then recursively scan those as well, i.e we support + " arbitrary levels of \input'ed-ness. + function! Tex_ScanFileForLabels(prefix) + call Tex_Debug("+Tex_ScanFileForLabels: grepping in file [".bufname('%')."]", "view") + + lcd %:p:h + exec "silent! grepadd! ".Tex_EscapeForGrep('\\label{'.a:prefix)." %" + + " Then recursively grep for all \include'd or \input'ed files. + let &suffixesadd = '.tex' + let &path = '.,'.g:Tex_TEXINPUTS + exec 0 + let wrap = 'w' + while search('^\s*\\\(input\|include\)', wrap) + let wrap = 'W' + + let filename = matchstr(getline('.'), '\\\(input\|include\){\zs.\{-}\ze}') + + let thisbufnum = bufnr('%') + + split + exec 'silent! find '.filename + + if bufnr('%') != thisbufnum + call Tex_Debug('Tex_ScanFileForLabels: scanning recursively in ['.bufname('%').']', 'view') + let foundCiteFile = Tex_ScanFileForLabels(a:prefix) + endif + + q + + if foundCiteFile + return 1 + endif + endwhile + endfunction " }}} " ============================================================================== ! " Functions for custom command completion " ============================================================================== " Tex_completion_{var}: similar variables can be set in package files {{{ |