[Vim-latex-cvs] A little review...
Brought to you by:
srinathava,
tmaas
From: Srinath A. <sr...@ee...> - 2003-01-17 10:40:45
|
... of the large number of changes I made recently. The initial way latex-suite used to get triggered was: 1. tex_latexSuite.vim would get sourced everytime. 2. It would source main.vim once for every buffer. 3. The first time it was sourced, main.vim would source each of the other files and from the second time on, just call SetTeXOptions(). Components which needed to set buffer local mappings would create globally visible functions which SetTeXOptions() would need to call. This had one obvious flaw because of point 2. It doesn't work with components which needed to do something every time we entered a buffer irrespective of whether its the first or the n^th time. For example, its not possible to write elegantly the functionality where the packages menu gets updated on every Filetype event. For example, if we do something like: 1. open a.tex 2. :e b.tex 3. :e a.tex in the original setup, hen after step 3, the packages menu would still show the stuff for b.tex... Apart from this obvious flaw which could have been solved with a little less effort, from a "do the right thing" point of view, it was just plainly bad design. There is too much inter dependency between the various modules, which means main.vim would need to be modified every time we wanted to change some other module. It might seem that one way to avoid interdependencies would have been to reduce tex_latexSuite.vim to: execute 'so '.s:path.'/latex-suite/*.vim' This is however not possible because we want to source the files in a certain order. There are ofcourse more obvious ways to overcome this problem. (like the brute force way of just making package/babel scan for whether the user uses babel with the 'german' option), but I think the present setup is the most scalable. Let me know if what I've done is not too clear or if you have other concerns. In summary, what I have done makes latex-suite behave like: 1. tex_latexSuite.vim gets sourced by vim every time a tex filetype event occurs. 2. It sources main.vim only once. _never again_ 3. It then just throws a LatexSuiteFileType event every time (including the first time). When main.vim gets sourced, it: 1. Sources each file in some nice order. 2. Sets up an au to catch the LatexSuiteFileType event to call SetTeXOptions() each time. Thus buffer local mappings are created for each tex file being edited. Other files which also need to set buffer local mappings follow the same procedure. packages.vim however does something extra 1. It sets up an au to call Tex_pack_updateall() on every LatexSuiteFileType event (which means it gets called for every buffer every time). 2. Tex_pack_updateall throws a LatexSuitePackagesScanned event after it is done "supporting" all the \usepackage's found. Finally, packages/babel catches the LatexSuitePackagesScanned event to customize the smart quotes setting. So to summarize, after about 5 hours of coding, I have a system which enables german users to edit both english and german files in the same vim session using some pretty nifty event handling mechanisms. I am absolutely sure that not more than about 1 person will find this useful. Ho well, if I was concerned with the value of my time, I wouldn't have started this thing in the first place... Besides, my meeting tomorrow got postponed, so I went a little overboard. I think this "little" programming binge has eaten up my quota for the coming week :( Hopefully, we will have some use for all this flexibity in the future. Srinath |