Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv26387
Modified Files:
packages.vim
Log Message:
Another great bug report from Ulrich Spoerlein.
Bug: When the following .tex file is opened with latex-suite, we get a
choose package prompt:
-----------------------------%<-----------------------------
\documentclass{report}
\usepackage[a4paper, pdftex, dvips, ps2pdf,
bookmarks, bookmarksopen, bookmarksnumbered,
colorlinks, linkcolor=blue, urlcolor=blue]{hyperref}
\usepackage{cite}
\begin{document}
\end{document}
-----------------------------%<-----------------------------
Cause: the original algorithm for finding packages failed when the
\usepackage definition was split across lines as shown here.
Solution: Rewrite the Tex_pack_all function to act much more robustly.
This method is able to account for multiple line definitions
pretty well.
Just to be on the safe side, ensure that Tex_pack_one is never
called with '' which causes the prompt.
Index: packages.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/packages.vim,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** packages.vim 30 Dec 2002 00:16:51 -0000 1.18
--- packages.vim 5 Jan 2003 02:19:26 -0000 1.19
***************
*** 3,7 ****
" Author: Mikolaj Machowski
" Created: Tue Apr 23 06:00 PM 2002 PST
! " Last Change: Sun Dec 29 04:00 PM 2002 PST
"
" Description: handling packages from within vim
--- 3,7 ----
" Author: Mikolaj Machowski
" Created: Tue Apr 23 06:00 PM 2002 PST
! " Last Change: Sat Jan 04 06:00 PM 2003 PST
"
" Description: handling packages from within vim
***************
*** 142,177 ****
endif
! exe 0
let beginline = search('\\begin{document}', 'W')
! exe 0
! let oldpack = ''
! let packname = ''
! while search('usepackage.*', 'W')
if line('.') > beginline
break
- elseif getline('.') =~ '^\s*%'
- continue
- elseif getline('.') =~ '^[^%]\{-}\\usepackage[^{]\{-}[%$]'
- let packname = matchstr(getline(search('^[^%]\{-}\]{', 'W')), '^.\{-}\]{\zs[^}]*\ze}')
- elseif getline('.') =~ '^[^%]\{-}\\usepackage'
- let packname = matchstr(getline("."), '^[^%]\{-}usepackage.\{-}{\zs[^}]*\ze}')
endif
! let packname = substitute(packname, '\s', '', 'g')
! if packname =~ ','
! let i = 1
! while 1
! let pname = Tex_Strntok(packname, ',', i)
! if pname == ''
! break
! endif
! let g:Tex_package_detected = g:Tex_package_detected.' '.pname
! call Tex_pack_one(pname)
! let i = i + 1
! endwhile
! elseif oldpack != packname
! let g:Tex_package_detected = g:Tex_package_detected.' '.packname
! call Tex_pack_one(packname)
endif
! let oldpack = packname
endwhile
--- 142,192 ----
endif
! 0
let beginline = search('\\begin{document}', 'W')
! 0
!
! " Scan
! while search('^\s*\\usepackage\_.\{-}{\_.\+}', 'W')
if line('.') > beginline
break
endif
!
! let saveA = @a
!
! " The following statement puts the stuff between the { }'s of a
! " \usepackage{stuff,foo} into @a. Do not use matchstr() and the like
! " because we can have things split across lines and such.
! exec "normal! /{\<CR>lv/}\<CR>h\"ay"
!
! " now remove all whitespace from @a. We need to remove \n and \r
! " because we can encounter stuff like
! " \usepackage{pack1,
! " newpackonanotherline}
! let @a = substitute(@a, "[ \t\n\r]", '', 'g')
!
! " Now we have something like pack1,pack2,pack3 with possibly commas
! " and stuff before the first package and after the last package name.
! " Remove those.
! let @a = substitute(@a, '\(^\W*\|\W*$\)', '', 'g')
!
! " This gets us a string like 'pack1,pack2,pack3'
! " TODO: This will contain duplicates if the user has duplicates.
! " Should we bother taking care of this?
! let g:Tex_package_detected = g:Tex_package_detected.@a
!
! " Finally convert @a into something like '"pack1","pack2"'
! let @a = substitute(@a, '^\|$', '"', 'g')
! let @a = substitute(@a, ',', '","', 'g')
!
! " ... so it can be used using one exec statement. Take care not to
! " call things with an empty argument otherwise, we will get a prompt
! " from the Tex_pack_one function.
! if @a != ''
! exec 'call Tex_pack_one('.@a.')'
endif
!
! " restore @a
! let @a = saveA
!
endwhile
|