Thread: [Vim-latex-devel] new dir for bibliography?
Brought to you by:
srinathava,
tmaas
From: Mikolaj M. <mi...@wp...> - 2003-04-08 08:45:30
|
Hello, I have got request to make possible looking for bibliography in other directory than directory of edited file. The best solution is to use grep but it needs such combination: elseif exists("s:type") && s:type =~ 'cite' let grep_prg = &grepprg set grepprg=grep\ -Hrn\ --include='*.bib'\ $*\ /dev/null exe 'silent! grep! "@.*{'.s:prefix.'" '.s:search_directory set grepprg=grep\ -Hrn\ --include='*.bbl'\ $*\ /dev/null exe 'silent! grepadd! "bibitem{'.s:prefix.'" '.s:search_directory set grepprg=grep\ -Hrn\ $*\ /dev/null exe 'silent! grepadd! "bibitem{'.s:prefix.'" %' let &grepprg = grep_prg call <SID>Tex_c_window_setup() With changing value of &grepprg. Alas, I don't know how to make it cross-platform. grep is easy to configure (GNU grep compatible grep tool as requirement and variable in texrc) but what about /dev/null? Without that lS doesn't work on terminal. Maybe something like that (example line): exe "set grepprg=".g:Tex_grepprg."\ -Hrn\ --include='*.bbl'\ $*".s:devnull And at the beginning: if has("unix") || has("mac_unix") || has("cygwin") let s:devnull = '\ /dev/null' else let s:devnull = '' endif How such compbination would work on other than Linux systems? m. |
From: Luc H. <her...@fr...> - 2003-04-08 11:41:03
|
Hello, * On Tue, Apr 08, 2003 at 10:12:18AM +0200, Mikolaj Machowski <mi...@wp...> wrote: > I have got request to make possible looking for bibliography in other > directory than directory of edited file. > > The best solution is to use grep but it needs such combination: > > elseif exists("s:type") && s:type =~ 'cite' > let grep_prg = &grepprg > set grepprg=grep\ -Hrn\ --include='*.bib'\ $*\ /dev/null > exe 'silent! grep! "@.*{'.s:prefix.'" '.s:search_directory BTW, the use of quotes or double quotes may cause a problem with &shellquote and &shellxquote. Anyway, I have tried to set &grepprg by hand, but still, I'm not able to use /usr/bin/grep (with your parameters) from my win32-vim + cygwin-bash as shell. Actually, I think I have never been able to do so. [ grepprg == grep\ -Hrn\ --include='*.bib'\ $* (± /dev/null) [ :grep '@.*{' /cygdrive/c/localtexmf/bibtex [ -> E303: Can not open the .swp file for [ "/cygdrive/c/localtexmf/bibtex/ASTORIA/astoria.bib", retrieval [ impossible ... or something like that. [ with: [ shellquote = [ shellxquote=" [ shell =c:\cygwin\bin\bash.exe [ shellredir =>%s 2>&1 [ shellpipe = 2>&1| tee [ shellslash = 1 The same command from bash works very well, and don't require I propose /dev/null as the last argument. > [...] > call <SID>Tex_c_window_setup() Where is this function defined ? > With changing value of &grepprg. Alas, I don't know how to make it > cross-platform. grep is easy to configure (GNU grep compatible grep tool > as requirement and variable in texrc) but what about /dev/null? > Without that lS doesn't work on terminal. Maybe something like that > (example line): > > exe "set grepprg=".g:Tex_grepprg."\ -Hrn\ --include='*.bbl'\ $*".s:devnull If the grep program is "findstr", ie the default win32-vim (called from the file-explorer or $COMSPEC), I doubt that -Hrn or --include will be supported. Some of its various useful options are: /n -> print line numbers /S -> recursion /R -> use regular expressions /M -> only the filename of the matching files /D:r,p -> search in a list of directories delimited by semi-comma. [it seems there is a little error in the doc at this point] > And at the beginning: > if has("unix") || has("mac_unix") || has("cygwin") Personnally, I'd rather test &sh =~'sh'. I found it more accurate than has('cygwin'). BTW, I have developped a little plugin aimed at easying the development of portable plugins -- I still have the documentation to finish and some tests to conduct. So far it seems quite functional.[1] > How such combination would work on other than Linux systems? Impossible to make it work on my system (cygwin-bash + win32-vim). :-( I don't know if it is due to an error of configuration on my side or anything else. [1] http://hermitte.free.fr/vim/ressources/system_utils.tar.gz html version of the documentation at: http://hermitte.free.fr/vim/ressources/vimfiles/doc/system_utils.html -- Luc Hermitte http://hermitte.free.fr/vim/ |
From: Mikolaj M. <mi...@wp...> - 2003-04-08 19:16:43
|
On Tue, Apr 08, 2003 at 01:33:50PM +0200, Luc Hermitte wrote: Thanks for your reply. Knowing there is no sense to put effort in grep issue I investigated how exactly LaTeX deals with bibliography files. Results are encouraging. There can be only one \bibliography command in file. It can be list of files with exact paths (no dealing with TEXINPUTS) separated with commas. We have only to find \bibliography and iterate through list and grep this files looking for bibkeys. This is easy. If there is no \bibliography we will grep current directory looking for *.bib and *.bbl files. No need for special variable. Also we should check MainFile if there is \bibliography command. But should we check it only if in current file this command doesn't exist? I think yes. But... Ok small "algorithm" Check if \bibliography exists in this file Yes No Grep files from list Grep files in directory \ / Y Grepadd current file for bibitem{ Check if in packages list is chapterbib Yes Check if current file is main file Yes No END Check if \bibliography exists in mainfile Yes No Grepadd files in list Grepadd files in dir of mainfile \ / Y Grepadd mainfile for bibitem{ The only problem I see is with .bbl files mentioned by Srinath. \include accepts only .tex files . In addition grepping *.bbl files (as is now) will grep half-products of regular bib files. I will change grep 'bibitem{' *.bbl into grep 'bibitem{ *.tex Is it right? Diagram above will change slightly but it is easy to imagine, I will not draw it again. > > call <SID>Tex_c_window_setup() > Where is this function defined ? tex/texviewer.vim Thanks again for your research. m. |