Re: [Vim-latex-devel] Re: [Vim-latex-cvs] vimfiles/plugin imaps.vim,1.7,1.8
Brought to you by:
srinathava,
tmaas
From: Srinath A. <sr...@fa...> - 2002-12-10 01:13:30
|
I am glad we are having this discussion on the way to implement this. Hopefully, we will be able to come up with a nice long term solution... > or some such. I type <C-J> and get "< 5 >" in Select mode. OK, > provided that <C-J> jumps to the "<label>" and does not delete "< 5 >"; > is this what happens, or does the place holder get deleted if I hit > <C-J> again? > > More realistic: lots of people are too lazy to use $\langle$ and > $\rangle$, so $<f, g>$ is likely to come up. > I think its essential to understand how placeholders are used... They are a bit more flexible than that. The only place where we need to ensure that there are no fake strings like '<f, g>' is in latex-suite itself. Its okay if the user has them at other places in the file. In this case, the user chooses a different value of g:Imap_PlaceHolder* variables. Just to be clear, the only real problem with hardcoding something like '<' or '<+' into latex-suite is only when latex-suite itself has some macros defined with strings like '<+something+>' without meaning for them to be placeholders. Also, <C-j> only deletes the placeholders if they are things like "<++>". If there is some explanation like "<+something+>", then it wont get deleted by pressing <C-j>. It will be replaced when you type some printable char. > If I try this with an HTML file, things get ugly. Need I say more? > Again, this is not an issue. The user will have different placeholder settings for html. Imap_JumpFunc() uses the buffer local value of the place holder settings for jumping. Again, just to emphasize, we are not trying to decide on a single character to be used across all languages/locales etc. We are just trying to decide for latex-suite... imaps.vim is kinda independent of this. (At present, Imap_PutTextWithMovement tries to replace certain patterns in the lhs with the user's place holder settings. This should be moved over to something in latex-suite). > 3. The "<++>" proposal might work, but I will make two predictions: > (a) Some crazed mathematician will decide that "<+f, g+>" is the right > notation for some sort of inner product. > (b) If there is not already an XML variant that uses "<+tags > like=3Dthis+>", there will be soon. Again, we only need to ensure that latex-suite itself doesn't use "<+" except as a placeholder. The crazy mathematician will have to change his setting for placeholders. The XML thing is not an issue as stated before. > IMAP(). I propose changing this to > > =09:call IMAP(ft, lhs, rhs1, ph1, rhs2, ph2, ...) > This is a beautiful solution. But consider that not all macros in latex-suite are triggered from IMAP(). Some of them do something like: inoremap <M-c> <C-r>=3DTex_MathCal()<CR> Then Tex_MathCal() does: =09return Imap_PutTextWithMovement("\\cite{=AB=BB)=AB=BB") So I suppose we will also have to change Imap_PutTextWithMovement() to accept variable arguments... Although the solution above does look like it could be _the_ correct solution, I have a feeling that hardcoding placeholders is not such a big deal at all... Assumption: latex-suite will never need to use strings like "<+something+>" except for demarcating placeholer characters. This assumtion is ****important***** Execution: envmacros.vim does: =09call Tex_IMAP('`/', '\frac{<++>}{<++>}<++>', 'tex') texrc does: =09let g:Imap_PlaceHolderStart =3D "\xab" =09let g:Imap_PlaceHolderEnd =3D "\xbb" We define a new function Tex_IMAP which replaces "<+" with the user's choice of g:Imap_PlaceHolderSetting and then call IMAP() with this new thing. Similary Imap_PutTextWithMovement is replaced with Tex_PutTextWithMovement. Finally, when the user press `/, he expands to \frac{|}{=AB=BB}=AB=BB where= | is the cursor position. If he wants he could set a different value of the place holder, if =AB=BB does not display nicely on his comp or if he uses a language where =AB=BB are legitimate chars. NOTE: imaps.vim will no longer try to replace the "<+" chars with [gb]:Imap_PlaceHolderStart. It will only use this setting in the Imap_JumpFunc(). Therefore, we could presumably have a user with an ftplugin/xml.vim file where he sets: =09let b:Imap_PlaceHolderStart =3D '?' =09let b:Imap_PlaceHolderEnd =3D '?' =09call IMAP('li`', '<li>??</li>??', 'xml') The crazy mathematician does =09" I have proved that the following strings occur with a probability =09" less than 1/(2*pi)^5*10e-12 in my files. I hope this is safe =09" enough. =09let b:Imap_PlaceHolderStart =3D '%xdf@#$' =09let b:Imap_PlaceHolderEnd =3D '*&#$*&' When he presses `/, he will get \frac{|}{%xdf@#$*&#$*&}%xdf@#$*&#$*& with | ofcourse denoting cursor position. Does this make everyone happy? Please try to come up with cases where the above system might fail... Okay... this mail is getting out of hand... Srinath |