Thread: [Vim-latex-devel] label viewing
Brought to you by:
srinathava,
tmaas
From: Mikolaj M. <mi...@wp...> - 2003-01-15 23:13:49
|
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 = line('.').' | normal! '.virtcol('.').'|' let g:curline = strpart(getline('.'), col('.') - 10) let g:prefix = matchstr(g:curline, '{\zs.\{-}$') redir @a exe 'silent g/\\label{'.g:prefix.'/p' redir END let g:lob = @a let g:lob = 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 have " something against chars like \n or ¤, with , these functions don't " have problems, but if I want to give whole lines , as separator can " cause problems let g:lob = substitute(g:lob, "\n", '¤', 'g') let g:common_label_prompt = Tex_CreatePrompt(g:lob, 1, '¤') . \ 'Enter number of label: ' let g:inp = input('Enter number of label:'."\n".g:common_label_prompt) if g:inp == '' exe pos return 0 endif let g:labelline = Tex_Strntok(g:lob, '¤', g:inp) let g:labelname = matchstr(g:labelline, '\\label{\zs.\{-}\ze}') exe 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 =~ "¤.\{-}\\label{[^¤]\{-}\\label{.\{-}¤" let g:glob = substitute(g:glob, "\(¤.\{-}\\label{.\{-}}\)\([^¤]\{-}\\label{.\{-}¤\)", "\1¤ 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 |
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 > > |
From: Mikolaj M. <mi...@wp...> - 2003-01-16 17:24:54
|
On Wed, Jan 15, 2003 at 04:00:31PM -0800, Srinath Avadhanula wrote: > 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() > " We want to search labels across files... not just the current > " file... We might cache this in some manner so we don't end up > " spawning shell commands every time the user does \label... > silent! grep \\label{ *.tex > " Open up a window showing the matches... This lets us use vim's own > " excellent quickfix capabilities. > cclose > cwindow 5 > " At this point we might even do something similar to what is done > " in RunLatex()... Open up the file corresponding to this match in a > " preview window... > wincmd 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? Great :) The idea to use quickfix is wonderful but I have to read something about it. Also I don't like to use IMAP here. quickfix and preview are some kind "agressive". Making it appears automagically... I wouldn't like this behaviour. Also mapping this to some key (let's say <F9>) make it easier to react on prefix (write \ref{fig and you will see only \labels for figures). This key will be "lost" but it is possible to make it context sensitive - another function will be called after \cite, another after \ref and maybe others. m. |
From: Srinath A. <sr...@fa...> - 2003-01-16 23:52:20
Attachments:
labelbrowser.vim
|
I just cooked up something which shows what I mean... Note that this is still a very basic version which doesn't have the syncing capability of compiler.vim... Eventually, we would like to make the quickfix window (in this case, the '--Label Browser---' window) sync with the appropriate tex window in preview mode... I am attaching a file called labelbrowser.vim. Place that in your ftplugin/tex/ directory and then when you either type \ref{ or press <F9> in normal mode, a window with the \label matches is shown... (You must have some tex files containing \label's in the directory of the file being edited). On Thu, 16 Jan 2003, Mikolaj Machowski wrote: > Great :) The idea to use quickfix is wonderful but I have to read > something about it. Also I don't like to use IMAP here. quickfix and > preview are some kind "agressive". Making it appears automagically... I am including this agressive behavior :) just now just to show its possible. Eventually, we might make this an option which is disabled by default... > I wouldn't like this behaviour. Also mapping this to some key (let's say > <F9>) make it easier to react on prefix (write \ref{fig and you will see only > \labels for figures). This key will be "lost" but it is possible to make Thats a cool idea... Infact, I think instead of both of us just getting our hands dirty and implementing something fast, we should discuss it like this... A really professional way to approach things like this is to write the documentation first... Here's my shot: ============================================================================== Label Browser *latex-suite-label-browser* This functionality is available via the Tex-Suite.Label menu or the :TLabel command. While editing a latex file, if you press <F9> after typing \ref{, latex-suite opens up a '--Label-Browser--' window. This window contains a list of \label's found in all the tex files found in the directory containing the present file being edited. Just below this window, a |preview-window| of the tex file containing the label is shown so you can get some context. Pressing <F9> while the label browser is being shown makes the cursor jump to the label browser window. Pressing <enter> on an item in this window inserts the corresponding label in the corresponding latex file. Moving up and down in the label browser window automatically syncs the preview window's display. If you press <F9> after something like '\ref{pat' then only labels starting with 'pat' will be shown. This is useful to narrow down references if you follow a consistent labeling scheme. See |ls-maps-label-browser| for how to customize the mapping for this functionality. See |ls-options-label-browser| for various options which affect the behavior ============================================================================== I still haven't written the |ls-options-label-browser| part of it :). In the meanwhile, you are welcome to add to the help suggest new modes of behavior etc... Srinath |
From: Mikolaj M. <mi...@wp...> - 2003-01-22 20:47:56
Attachments:
labv.vim
|
On Thu, Jan 16, 2003 at 03:52:16PM -0800, Srinath Avadhanula wrote: > I just cooked up something which shows what I mean... Note that this is > still a very basic version which doesn't have the syncing capability of > compiler.vim... Eventually, we would like to make the quickfix window > (in this case, the '--Label Browser---' window) sync with the > appropriate tex window in preview mode... > I am attaching a file called labelbrowser.vim. Place that in your > ftplugin/tex/ directory and then when you either type \ref{ or press > <F9> in normal mode, a window with the \label matches is shown... > (You must have some tex files containing \label's in the directory of > the file being edited). Hmm. I don't like idea of results caching - what about new \label items? here is my version. this is rather prototype and needs completion and polishing but before I do more I'd like to hear what do you think about it. Your version was causing problems with redrawing of screen. > On Thu, 16 Jan 2003, Mikolaj Machowski wrote: > > Great :) The idea to use quickfix is wonderful but I have to read > > something about it. Also I don't like to use IMAP here. quickfix and > > preview are some kind "agressive". Making it appears automagically... > I am including this agressive behavior :) just now just to show its > possible. Eventually, we might make this an option which is disabled by > default... I commented this. IMAP here causes problems. Try with <F9> in Normal mode > In the meanwhile, you are welcome to add to the help suggest new modes > of behavior etc... What about turning off preview window? This can lead to some problems. Previewing files opens them and this is not always desired behaviour. Mikolaj |