Re: [Vim-latex-devel] label viewing
Brought to you by:
srinathava,
tmaas
From: Srinath A. <sr...@fa...> - 2003-01-16 00:00:43
|
Hey Mikolaj, I was actually thinking of a different way of implementing this... (I haven't even started)... Here's my take: call IMAP('\ref{', "\<C-o>:Tex_ListLabels()\<CR>", 'tex') And Tex_ListLabels() should actually do something like: function! Tex_ListLabels() =09" We want to search labels across files... not just the current =09" file... We might cache this in some manner so we don't end up =09" spawning shell commands every time the user does \label... =09silent! grep \\label{ *.tex =09" Open up a window showing the matches... This lets us use vim's own =09" excellent quickfix capabilities. =09cclose =09cwindow 5 =09" At this point we might even do something similar to what is done =09" in RunLatex()... Open up the file corresponding to this match in a =09" preview window... =09wincmd p endfunction And if possible, we should make this function behave like RunLatex() so that it also opens up the corresponding file in preview mode when we are on a line in the cwindow... (So that we have some context aroudnd the \label) Hope you are getting what I mean... Try making some $\mistake$ in a tex file and compiling it... I was thinking that the label/citation browser would behave similarly... What do you think? Srinath On Thu, 16 Jan 2003, Mikolaj Machowski wrote: > Hello, > > I began to write function to view label names and have problems... > It works in this way: write \ref{ press <F9> you should see > lines with \label ;choose number and nothing. If you wrote > \ref{i you will see only list of labels which began on i. > > ---------------------- > " For making labels > " > inoremap <F9> <C-o>:call Labtest()<cr> > > > function! Labtest() > > let pos =3D line('.').' | normal! '.virtcol('.').'|' > > =09let g:curline =3D strpart(getline('.'), col('.') - 10) > =09let g:prefix =3D matchstr(g:curline, '{\zs.\{-}$') > > =09redir @a > =09exe 'silent g/\\label{'.g:prefix.'/p' > =09redir END > > =09let g:lob =3D @a > =09let g:lob =3D substitute(g:lob, "\n", '', '') > " here is first problem: I'd like to present whole lines with \label tag > " to give some context (also it would take some time to process each > " line to get only \label tag)[1] but Tex_CreatePromt and Tex_Strntok hav= e > " something against chars like \n or =A4, with , these functions don't > " have problems, but if I want to give whole lines , as separator can > " cause problems > =09let g:lob =3D substitute(g:lob, "\n", '=A4', 'g') > > > =09let g:common_label_prompt =3D Tex_CreatePrompt(g:lob, 1, '=A4') . > =09=09=09=09\ 'Enter number of label: ' > > =09let g:inp =3D input('Enter number of label:'."\n".g:common_label_promp= t) > > =09if g:inp =3D=3D '' > =09=09exe pos > =09=09return 0 > =09endif > > =09let g:labelline =3D Tex_Strntok(g:lob, '=A4', g:inp) > =09let g:labelname =3D matchstr(g:labelline, '\\label{\zs.\{-}\ze}') > > =09exe pos > " As usual I have problems with simple things :(. How put > " g:labelname.'}' after \ref{, \pageref{ or similar. > > endfunction > --------------------- > > > [1] When two \label are in one line can be easily solved with > if g:lob =3D~ "=A4.\{-}\\label{[^=A4]\{-}\\label{.\{-}=A4" > =09let g:glob =3D substitute(g:glob, "\(=A4.\{-}\\label{.\{-}}\)\([^=A4]\= {-}\\label{.\{-}=A4\)", > =09=09"\1=A4 cont -> \2", 'g') > endif > > OK, I didn't test it but problem is possible to solve and IMO faster > then iterate through whole g:glob to get only \label{..} things. > > > Mikolaj > > > ------------------------------------------------------- > This SF.NET email is sponsored by: A Thawte Code Signing Certificate > is essential in establishing user confidence by providing assurance of > authenticity and code integrity. Download our Free Code Signing guide: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en > _______________________________________________ > Vim-latex-devel mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vim-latex-devel > > |