On Sun, Apr 26, 2009 at 01:55:08AM +0100, Thomas Ibbotson wrote:
> Hi,
>
> Here's another patch to texviewer.vim against the current SVN version. This 
> now matches bibitems with labels i.e. \bibitem[foo]{bar} when using a 
> \thebibliography environment.
>
> I also noticed that \cite completion did not work for a file with a 
> \thebibliography environment unless I put the following line in my .vimrc:
>
> let g:Tex_UseCiteCompletionVer2 = 0
>
> Is this just unfinished? I have had a look, and haven't thought of an easy 
> way to fix this, but I'm happy to come up with something if this isn't 
> already being currently worked on.
>
> Thanks,
>
> Tom

Hi; 
yet another patch, working over Thomas' one. The previous patch
identified lines with \bibitem[...]{...} for completion, but the
completion worked oddly. This one works fine, at least in the cases I
tested it with.
Also, I added some spaces to the regexps, since something like
\bibitem  [A]   {a}
is understood by latex, so it should be understood by vim-latex.
I did not add possible newlines in the middle: latex understands
\bibitem
        [A] {a}
and the current patch doesn't.

Also: I missed the completion for cites for quite a long time, until
Thomas suggested to set the variable g:Tex_UseCiteCompletionVer2.
Thanks! Besides this, as he says, it is not a good thing having to set
this variable. Is it part of an unfinished work?

Best,
Matías

--- texviewer-new.vim   2009-04-29 09:13:30.000000000 -0300
+++ texviewer.vim       2009-04-29 09:08:37.000000000 -0300
@@ -380,10 +380,10 @@
 function! s:Tex_CompleteRefCiteCustom(type)
 
        if a:type =~ 'cite'
-               if getline('.') =~ '\\bibitem\s*{'
-                       let bibkey = matchstr(getline('.'), 
'\\bibitem\s*{\zs.\{-}\ze}')
+               if getline('.') =~ '\\bibitem{'
+                       let bibkey = matchstr(getline('.'), 
'\\bibitem{\zs.\{-}\ze}')
                else
-                       let bibkey = matchstr(getline('.'), 
'\\bibitem\s*\[.\{-}\]\s*{\zs.\{-}\ze}')
+                       let bibkey = matchstr(getline('.'), 
'{\zs.\{-}\ze\(,\|$\)')
                endif
                let completeword = strpart(bibkey, strlen(s:prefix))
 
@@ -616,7 +616,7 @@
                split
                lcd %:p:h
                call Tex_Debug("silent! grepadd! 
".Tex_EscapeForGrep('\\bibitem{'.a:prefix)." %", 'view')
-               call Tex_Grepadd('\\bibitem\s*[\[|{]'.a:prefix, "%")
+               call Tex_Grepadd('\\bibitem{'.a:prefix, "%")
                q
                
                return 1
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Vim-latex-devel mailing list
Vim-latex-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vim-latex-devel

Reply via email to