Thread: [Vim-latex-cvs] vimfiles/ftplugin/latex-suite/packages ngerman,NONE,1.1
Brought to you by:
srinathava,
tmaas
From: <mi...@us...> - 2003-01-15 23:14:54
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/packages In directory sc8-pr-cvs1:/tmp/cvs-serv32100 Added Files: ngerman Log Message: new package file --- NEW FILE: ngerman --- " For now just define the smart quotes. let g:Tex_SmartQuoteOpen = '"`' let g:Tex_SmartQuoteClose = "'\"" " vim:ft=vim:ff=unix: |
From: Benji F. <be...@me...> - 2003-01-16 02:01:55
|
mi...@us... wrote: > Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/packages > In directory sc8-pr-cvs1:/tmp/cvs-serv32100 > > Added Files: > ngerman > Log Message: > new package file > > --- NEW FILE: ngerman --- > " For now just define the smart quotes. > let g:Tex_SmartQuoteOpen = '"`' > let g:Tex_SmartQuoteClose = "'\"" First of all, the close quote should be "' instead of '" . Second, is there any reason not to have simply :execute "source" expand("%:p:h") . "/german" in this file? Finally, is there any way to get these files :source'd when the file contains \usepackage[german]{babel} instead of \usepackage{german} ? --Benji |
From: Srinath A. <sr...@fa...> - 2003-01-16 02:39:03
|
On Wed, 15 Jan 2003, Benji Fisher wrote: > :execute "source" expand("%:p:h") . "/german" > Agreed. Although it should be: execute 'source '.expand('<sfile>:p:h').'/german' (<sfile> instead of %) > \usepackage[german]{babel} > > instead of > > \usepackage{german} > As of now, there isn't. During the scan for \usepcackage's, the g:Tex_pack_supported is created which lists the packages detected... Unless a variable like g:Tex_{pack}_options or something similar is created, this is not possible. This is actually not too hard to implement, but even if it is implemented, I dont know how to make the tex quotes function use this information. We will have to revert to the strategy of modifying that function itself... (But I dont like that strategy too much because its not really scalable). Any ideas? Srinath |
From: Mikolaj M. <mi...@wp...> - 2003-01-16 17:24:55
|
On Wed, Jan 15, 2003 at 06:39:00PM -0800, Srinath Avadhanula wrote: > On Wed, 15 Jan 2003, Benji Fisher wrote: > > :execute "source" expand("%:p:h") . "/german" > > > Agreed. Although it should be: > execute 'source '.expand('<sfile>:p:h').'/german' > (<sfile> instead of %) > > \usepackage[german]{babel} > > > > instead of > > > > \usepackage{german} > > > As of now, there isn't. During the scan for \usepcackage's, the > g:Tex_pack_supported is created which lists the packages detected... > Unless a variable like g:Tex_{pack}_options or something similar is > created, this is not possible. This is actually not too hard to > implement, but even if it is implemented, I dont know how to make > the tex quotes function use this information. We will have to revert to > the strategy of modifying that function itself... (But I dont like that > strategy too much because its not really scalable). > Any ideas? Here simple solution package file 'babel': ------- function! Lookfor() let g:pos = line('.').' | normal! '.virtcol('.').'|' let g:line = search('\\usepackage.*{babel}', 'w') if getline(g:line) =~ 'german' source $VIMLATEXMAINPATH/packages/german endif exe g:pos endfunction call Lookfor() " vim:ft=vim:ff=unix: --------- Works for me. Aha, small cheat: $VIMLATEXMAINPATH is defined in main.vim. IMO this is not bad idea - calculating path in each file which needs this information in not very clear. But this in not necessarily good solution. This sources whole package file with its menus and specific commands which is not always cause with babel package. IIRC this turns on only hyphenation, gives access to special letters, and redefines \chapter and similar commands. For (n)german it works. I have wonderful polski package which does many, many more. Maybe Luc can say more? m. ps. To Srinath: g: variables are only for debugging purposes ;) |
From: Benji F. <be...@me...> - 2003-01-16 17:47:55
|
Mikolaj Machowski wrote: > On Wed, Jan 15, 2003 at 06:39:00PM -0800, Srinath Avadhanula wrote: > >>On Wed, 15 Jan 2003, Benji Fisher wrote: >> >>>:execute "source" expand("%:p:h") . "/german" >>> >> >>Agreed. Although it should be: >>execute 'source '.expand('<sfile>:p:h').'/german' >>(<sfile> instead of %) >> >>>\usepackage[german]{babel} >>> >>>instead of >>> >>>\usepackage{german} >>> >> >>As of now, there isn't. During the scan for \usepcackage's, the >>g:Tex_pack_supported is created which lists the packages detected... >>Unless a variable like g:Tex_{pack}_options or something similar is >>created, this is not possible. This is actually not too hard to >>implement, but even if it is implemented, I dont know how to make >>the tex quotes function use this information. We will have to revert to >>the strategy of modifying that function itself... (But I dont like that >>strategy too much because its not really scalable). >>Any ideas? > > > Here simple solution > package file 'babel': > ------- > function! Lookfor() > let g:pos = line('.').' | normal! '.virtcol('.').'|' > let g:line = search('\\usepackage.*{babel}', 'w') > if getline(g:line) =~ 'german' > source $VIMLATEXMAINPATH/packages/german > endif > exe g:pos > endfunction > > call Lookfor() > > " vim:ft=vim:ff=unix: > --------- > Works for me. Aha, small cheat: $VIMLATEXMAINPATH is defined > in main.vim. IMO this is not bad idea - calculating path in each file > which needs this information in not very clear. > > But this in not necessarily good solution. This sources whole package > file with its menus and specific commands which is not always cause with > babel package. IIRC this turns on only hyphenation, gives access to > special letters, and redefines \chapter and similar commands. For > (n)german it works. I have wonderful polski package which does many, > many more. Maybe Luc can say more? > > m. > > ps. To Srinath: g: variables are only for debugging purposes ;) I was going to ask about the g: vars. Why wrap it in a function? Just use s: instead of g: . Or do you see the Lookfor() function as being needed in other scripts? I only write in English, so I am not familiar with the difference between \usepackage[mylang]{babel} and \usepackage{mylang} . That said, I have a suggestion: have files babel, german, and german-babel (or babel-german or even babel/german) in the packages directory. The german file, and the babel file if german is given as an option, will :source the german-babel file. So far, the german file will not do anything else, but it may in the future. I would rather parse the \usepackage[...]{babel} line more carefully, rather than just test whether it matches 'german'. --Benji |
From: Benji F. <be...@me...> - 2003-01-16 04:43:07
|
Srinath Avadhanula wrote: > On Wed, 15 Jan 2003, Benji Fisher wrote: > > >>:execute "source" expand("%:p:h") . "/german" >> > > > Agreed. Although it should be: > > execute 'source '.expand('<sfile>:p:h').'/german' > > (<sfile> instead of %) > > >>\usepackage[german]{babel} >> >>instead of >> >>\usepackage{german} >> > > As of now, there isn't. During the scan for \usepcackage's, the > g:Tex_pack_supported is created which lists the packages detected... > Unless a variable like g:Tex_{pack}_options or something similar is > created, this is not possible. This is actually not too hard to > implement, but even if it is implemented, I dont know how to make > the tex quotes function use this information. We will have to revert to > the strategy of modifying that function itself... (But I dont like that > strategy too much because its not really scalable). > > Any ideas? I was thinking that if babel is one of the packages found, then whatever language is given as an option should be added as a package. If the file contains \usepackage[foo]{babel} then pretend that it includes \usepackage{foo} Perhaps one way to do this would be to add a packages/babel file that finds the options, and fakes including the packages. --Benji |
From: Srinath A. <sr...@fa...> - 2003-01-16 07:02:04
|
On Wed, 15 Jan 2003, Benji Fisher wrote: > I was thinking that if babel is one of the packages found, then > whatever language is given as an option should be added as a package. > If the file contains > > \usepackage[foo]{babel} > > then pretend that it includes > > \usepackage{foo} This is still going to require that we scan for options and create a variable such as g:Tex_{package}_options Now Tex_pack_all() scans the file looking for \usepackage's... I do not think it will be a good idea to make it also do something based on which pacakges it found and what options were used in each etc. That approach will mean that each time we come across a new issue like this, we will have to change that function... What about something more "long term"... I was recently looking at the excellent cvscommand.vim plugin and one thing which that plugin uses, which we haven't done so far is user generated autcommands... I think using this mechanism is one way to go... After the initial scan for \usepackage's, Tex_pack_all() throws an event: silent! do TexPackages User TexPackagesScanned If a package wants to, it can catch this event. For example, packages/babel could do: augroup TexPackages au TexPackages User TexPackagesScanned call SetQuotes() augroup END fun! SetQuotes() if g:Tex_pack_supported =~ babel if g:Tex_babel_option =~ 'german' let open = "\"`" let close = "\"'" elseif g:Tex_babel_option =~ 'french' let open = '<<' let close = '>>' endif endif endfun This mechanism effectively lets each package work for itself without making Tex_pack_all() do it... > Perhaps one way to do this would be to add a packages/babel file that > finds the options, and fakes including the packages. The package files should not be required to scan for \usepackage's and what options were used etc. That should be done by some latex-suite function like Tex_pack_all(). The package files should only have the intelligence to use this information in some way... Although this mechanism might seem complicated at first glance, I do not think it is... The advantage is that it will be eminently scalable... Using this mechanism, we might even have gotten away with not creating the german and ngerman packages at all... Just creating the SetQuotes function and the autocommand above would have been sufficient... Srinath |