Re: [Vim-latex-devel] Completion of Tcommands
Brought to you by:
srinathava,
tmaas
From: Luc H. <her...@fr...> - 2003-07-15 00:30:51
|
Hello, * On Sun, Jul 13, 2003 at 11:36:28PM -0700, Srinath Avadhanula <sr...@fa...> wrote: > > My idea is that TTemplate, TMacros, ... would invoke the same > > function but with different built-in parameters. > > > As of now, the templates, custom macros and IMAP() functions in > latex-suite are all handled by a central > IMAP_PutTextWithMovement() function with differing arguments and > wrapper functions (for example, TTemplate provides a prompt for the > template files etc). So we do not really repeat any work. The jump > function and marker functionality is all in plugin/imaps.vim. OK. But the expansion of "!com!...!com!" and "!exe!...!exe!", ... are unique to templates, if I am correct. Feature which would be very interresting to have with macros/packages/... <adv.> > Also, one sufficiently important implementation issue in the IMAP() > function is that you do not have to bind all expansions to non-keyword > characters like <C-r><space> or <C-r><tab> etc. Most expansions in > latex-suite are for example triggered just as :imaps work except for > being able to correct, no timeout etc. Basically, only the last > character of the first argument of an IMAP() is actually :map'ped to a > LookupCharacter() function. A reverse lookup over previously typed > characters is made whenever such a character is encountered and if > there is a possible completion, it is used... This enables you to have > 2-key mappings like `8 -> \infty which would have been pretty annoying > to use if we had to type 8<C-r><tab> each time... That is not really an issue, µTemplate is easy to enhance with something like (syntax not tested): function s:BindTemplate(file) let the_map = fnamemodify(a:file, ":e") call IMAP_smart_bind(s:the_leader.the_map, \ "\<c-o>:MuTemplate tex/".the_map) " IMAP_smart_bind() beeing the core of the IMAP_... functions. endfunction command! BindTemplate :call s:BindTemplate("<args>") SearchInRuntime! :BindTemplate template/tex/template.* As a result, if you type "`figure", it will get expanded with the right template-file -- it is also possible to automatically build more complex/specific keybindings than this simplistic one. But, it is already (at this time) possible to use it a stubs-expander that expands on back-quotes (like Dr Chip Campbell's stubs-expander) -- by just mapping the expansion to "`" instead of "<c-r><tab>", ... => :imap <buffer> ` <Plug>MuT_cword (if you'd rather use <F5> ... it is easy to adapt ... ; for personal reasons, I've chosen <c-r><tab>) Which is IMHO more interresting than "`figure" because "f`", "fi`", ..."figure`" also work -- and if several choices are available ... they will be proposed to the end-user. [Little remark: the back-quote is not a French-friendly character as it is hard-binded to <altgr-7>. French keyboards are definitively CS-unfriendly :( ] </adv.> But that was not my initial point. My main point is: wouldn't it be more interresting to - concentrate on building a really powerfull templates-expander, - and wrap its calls into functions/commands/menus for macros/templates/packages. BTW, i fixed some little problems from the original µTemplate plugin ; even one (and a half) i personnaly introduced (two :<range>substitute calls for "compute" and "execute" was a awkward! ; several "execute" commands have no reasons to be on a same line.) <adv.> Last parenthesis. The only things you may consider as a lack in my current version on µTemplate: - a little patch is still to be applied regarding non-latin1 issues - placeholders are not converted by the plugin, but instead inserted through a call to a dedicated function. - the filenames of the templates are quite heavy ({rtp}/template/template.{the_real_name}) </adv.> ______________ > BTW, very recently I started to have to compile some files multiple > times and therefore quickly felt the need for a function like > TKMakeDVI in tex-tools.vim (part of your latex ftplugin package). I > looked at it and have been extracting parts of it to use in > latex-suite. Feel free to do so ! > I wish to borrow the basic logic of the multiple compilations, but I > wish to implement various things like TKFilesDiffer() differently to > make it cross-platform without a lot of platform detection logic... This function was definitivelly an headache ! I made minor modifications on Tomer Kol's initial function, but still it is not perfect :-( > I have a very rough (and incomplete) draft of this on a non-MAIN > branch in the vim-latex cvs tree. > Another implementation issue is that I have a parallel python > implementation of the same thing and the script should automatically > detect python and use the python function instead so all the things > like filediff's etc can be handled via python much more cleanly than > in viml. Sounds like a good idea! > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/vim-latex/vimfiles/ftplugin/tex/Attic/latexm.vim?rev=1.1.2.3&only_with_tag=latex-multi-compile&content-type=text/vnd.viewcvs-markup After a quick check: - [adv.] I have dedicated a plugin to portability issues. For instance it defines a function SysCat() that returns the name of the external program to use according to the current system -- and the path to the parameter-files is correctly converted! -> system_utils.vim - Why exec 'silent! 0r! '.g:Tex_CatCmd.' '.a:filename and not just: if fileexists(a:filename) exec 'silent! 0r '.a:filename endif ? It would reduce the problems we can experience because of external programs -- another source of headaches. - Why if search(a:regexp, 'w') let retVal = 1 else let retVal = 0 endif instead of: let reVal = search(a:regexp, 'w') > 0 ? I'm a militant for the direct use of boolean expressions whenever we have "if expression then a=true else a=false endif" :) _________ Otherwise, I would have a request (partly implemented in my ftplugin). I'd like to have the choice of the way used to define the main TeX document between: - using a [bg]:dedicated_variable_for_this (whatever the final name is) - or using mainfile.{theproject} (or another name i don't remember) as you originally planned - or using a Makefile (if the right conditions are fulfilled) - or using the name of the current buffer. -- Luc Hermitte http://hermitte.free.fr/vim/ |