Re: [Vim-latex-devel] new version of imaps.vim
Brought to you by:
srinathava,
tmaas
From: Benji F. <be...@me...> - 2002-12-18 16:58:06
|
Srinath Avadhanula wrote: > > On Mon, 16 Dec 2002, Benji Fisher wrote: > > Well, its not a complete loss. All the simplifications in imaps.vim will > still be retained... Basically, IMAP() and LookupChar...() have both > been reworked compelteley. And it is conceptually simpler, which is > a benefit for end users I suppose... Yes, they are simpler. This is good for us, but I am not sure it affects the end user directly. > Hmm... The reason I prefered the other way was that that way, all those > places in latex-suite which use IMAP() and Imap_Put...() will not be > changed much. More laziness speaking... But I suppose its better to be > safe than sorry... Will have to do a search and replace across all files > to change > > Tex_IMAP(lhs, rhs, ft) > > to IMAP(lhs, rhs, ft, '<+', '+>') > > and the same for Tex_PutTextWithMovement... > > But I am wondering if there are places where an IMAP() call is broken > across lines using \ or something. I think something like this should work. Wrap it in :argdo . :g/\<IMAP\s*(/execute "normal! %i, '<+', '+>'\<Esc>" >> I may have a little time tomorrow to work on this. (Morning: >>write solutions to exam. Afternoon: proctor the exam. How do I fit in >>some vimming? Bring my laptop and use the school's wireless network! ;) >> Then comes the grading ...) > > > Heh :) I was actually looking at the course web-site for what youre > teaching. Looks like a fun thing to teach... Yes, it was fun, but now I have to grade the final exams. :-( Luckily, it is a pretty small class. I just committed a new version of imaps.vim (in the b-newimaps branch). I tested it with several variants (including phs = phe = "|") and it seems to work pretty well. I have not yet edited the rest of the files to use the new/old syntax. Since the new calling syntax is compatible with the original, it might be simpler to import the new imaps.vim into the main branch, and just replace Tex_IMAP() with IMAP(). Either way, I should finish grading before I do any more work on this. Implementation notes: 1. I decided the best method was for IMAP() to store phs and phe in script variables. These (along with rhs) are read by LookupChar() and passed to IMAP_PutTextWithMovement(). This avoids duplicating code between the two IMAP*() functions, and seems pretty robust in terms of allowing the default place holders in the rhs. I have not yet documented this in the comments... 2. It would be easy to calculate lengths and use "\<bs>" and "\<space>" to position the cursor. One of us put in a comment that this does not work because strlen() may not return the right thing, and this depends on the encoding. :-( Instead, I chose to use the following marker: let marker = phs . phs . phe . phe using the "input" place holders. I think this is quite safe, but there are a lot of cases to consider: these are/are not the default place holders, ... Anyway, the end op IMAP_PutTextWithMovement() is long and complicated, adn perhaps there is a simpler way. --Benji |