Thread: [Vim-latex-cvs] vimfiles/plugin imaps.vim,1.14,1.15
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2002-12-27 22:42:52
|
Update of /cvsroot/vim-latex/vimfiles/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv887 Modified Files: imaps.vim Log Message: . changes from the b-newpackages branch... Index: imaps.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** imaps.vim 24 Dec 2002 12:51:06 -0000 1.14 --- imaps.vim 27 Dec 2002 22:42:50 -0000 1.15 *************** *** 8,12 **** " while preserving filetype indentation. " ! " Last Change: Tue Dec 24 04:00 AM 2002 PST " " Documentation: {{{ --- 8,12 ---- " while preserving filetype indentation. " ! " Last Change: Fri Dec 27 02:00 PM 2002 PST " " Documentation: {{{ |
From: <sri...@us...> - 2002-12-30 10:54:52
|
Update of /cvsroot/vim-latex/vimfiles/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv405 Modified Files: imaps.vim Log Message: Bug: When we trigger a mapping near the end of the line, things go bad. Cause: The "marker" or the "very improbable string" which is used by IMAP_PutTextWithMovement() to mark the beginning of the left-hand side contains spaces! This causes expansions near the end of a line to trigger line breaks (if 'fo' contains t, which is default and tw != 0), so that the marker text is broken across lines... Havoc ensues. Solution: remove spaces from marker text. Index: imaps.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** imaps.vim 24 Dec 2002 12:51:06 -0000 1.14 --- imaps.vim 30 Dec 2002 10:54:49 -0000 1.15 *************** *** 8,12 **** " while preserving filetype indentation. " ! " Last Change: Tue Dec 24 04:00 AM 2002 PST " " Documentation: {{{ --- 8,12 ---- " while preserving filetype indentation. " ! " Last Change: Mon Dec 30 02:00 AM 2002 PST " " Documentation: {{{ *************** *** 269,273 **** " A very rare string: Do not use any special characters here. This is used " for moving to the beginning of the inserted text. ! let marker = '<!--- @#% Start Here @#% ----!>' let markerLength = strlen(marker) --- 269,273 ---- " A very rare string: Do not use any special characters here. This is used " for moving to the beginning of the inserted text. ! let marker = '<!---@#%_Start_Here_@#%----!>' let markerLength = strlen(marker) |
From: Srinath A. <sr...@fa...> - 2002-12-30 11:03:58
|
I just noticed another problem with the long marker string. We are triggering line breaks unecessarily. Just doing $$ 10 spaces away from EOL causes the $$ to slip into the next line. This will have to be fixed too... Maybe Benji's original idea of using phs.phs instead of the marker string... (maybe check to see if phs != phe before this...) Srinath On Mon, 30 Dec 2002 sri...@us... wrote: > Update of /cvsroot/vim-latex/vimfiles/plugin > In directory sc8-pr-cvs1:/tmp/cvs-serv405 > > Modified Files: > imaps.vim > Log Message: > Bug: When we trigger a mapping near the end of the line, things go bad. > Cause: The "marker" or the "very improbable string" which is used by > IMAP_PutTextWithMovement() to mark the beginning of the left-hand side > contains spaces! This causes expansions near the end of a line to > trigger line breaks (if 'fo' contains t, which is default and tw != 0), > so that the marker text is broken across lines... Havoc ensues. > Solution: remove spaces from marker text. > |
From: Benji F. <be...@me...> - 2002-12-30 13:39:35
|
Srinath Avadhanula wrote: > I just noticed another problem with the long marker string. We are > triggering line breaks unecessarily. Just doing $$ 10 spaces away from > EOL causes the $$ to slip into the next line. This will have to be fixed > too... > > Maybe Benji's original idea of using phs.phs instead of the marker > string... (maybe check to see if phs != phe before this...) > > Srinath Maybe we should go back to the idea of positioning the cursor with {count}<bs> and {count}<space> (in Normal mode). The comment in the code says that the problem is that strlen() returns different values depending on the encoding. Does anyone remember how to produce an example of this? Did we ever try :let n = strlen(substitute(text, ".", "x", "g")) to calculate the right number of <bs> or <space> characters to use? --Benji |
From: Srinath A. <sr...@fa...> - 2002-12-31 07:28:21
|
On Mon, 30 Dec 2002, Benji Fisher wrote: > Maybe we should go back to the idea of positioning the cursor with > {count}<bs> and {count}<space> (in Normal mode). The comment in the > code says that the problem is that strlen() returns different values > depending on the encoding. Does anyone remember how to produce an > example of this? Did we ever try > > :let n =3D strlen(substitute(text, ".", "x", "g")) > Yes. Positioning using movement is the best... The problem I ran across was that if you do something like :set encoding=3Dutf8 :let bar =3D "=AB" =09(where the =AB character is typed using <C-v><<) :echo strlen(bar) 2 Can this problem be taken care of using the change in encoding etc? Hmm... I see that :echo strlen(iconv(bar, &encoding, 'latin1')) 1 :echo strlen(substitute(bar, '.', 'x', 'g')) 1 So those two methods might work... It will be a definite improvement over the current "hack". On a different note: imaps.vim now contains: =09let textEnc =3D iconv(text, "latin1", &enc) =09[snip] =09" If there are no place holders, just return the text. =09if textEnc !~ '\V'.phs.'\.\{-}'.phe =09=09return text =09endif Shouldn't the comparision be: =09" If there are no place holders, just return the text. =09if textEnc !~ '\V'.phsEnc.'\.\{-}'.pheEnc =09=09return text =09endif Maybe this is why Fabio is having that problem? I am wary of making any changes here because I haven't thought about this as much as you have... Srinath |
From: Benji F. <be...@me...> - 2002-12-31 14:58:58
|
Srinath Avadhanula wrote: > On Mon, 30 Dec 2002, Benji Fisher wrote: > > Yes. Positioning using movement is the best... The problem I ran across > was that if you do something like > > :set encoding=utf8 > :let bar = "?" > (where the ? character is typed using <C-v><<) > :echo strlen(bar) > 2 > > Can this problem be taken care of using the change in encoding etc? > Hmm... I see that > :echo strlen(iconv(bar, &encoding, 'latin1')) > 1 > :echo strlen(substitute(bar, '.', 'x', 'g')) > 1 > > So those two methods might work... It will be a definite improvement > over the current "hack". I think we should try this. Another new branch? Personally, I prefer the substitute() approach over iconv(), because I think I understand it better. > On a different note: > > imaps.vim now contains: > > let textEnc = iconv(text, "latin1", &enc) > [snip] > > " If there are no place holders, just return the text. > if textEnc !~ '\V'.phs.'\.\{-}'.phe > return text > endif > > Shouldn't the comparision be: > > " If there are no place holders, just return the text. > if textEnc !~ '\V'.phsEnc.'\.\{-}'.pheEnc > return text > endif > > Maybe this is why Fabio is having that problem? > > I am wary of making any changes here because I haven't thought about > this as much as you have... Well, I have experimented a lot. Remember the experiments I asked you to repeat, :let foo = "\xab" :echo foo =~ foo :echo iconv(foo, 'latin1', &enc) =~ foo Your variant may also work, but I did it this way on purpose. AFAICT it works. --Benji |
From: Mikolaj M. <mi...@wp...> - 2003-01-01 22:34:23
|
On Tue, Dec 31, 2002 at 10:06:30AM -0500, Benji Fisher wrote: > I think we should try this. Another new branch? Personally, I > prefer the substitute() approach over iconv(), because I think I > understand it better. substitute() is in all Vims. iconv() need |+iconv|. Mikolaj |
From: Benji F. <be...@me...> - 2003-01-06 15:41:10
|
Benji Fisher wrote: > Srinath Avadhanula wrote: > >> On Mon, 30 Dec 2002, Benji Fisher wrote: >> >> Yes. Positioning using movement is the best... The problem I ran across >> was that if you do something like >> >> :set encoding=utf8 >> :let bar = "?" >> (where the ? character is typed using <C-v><<) >> :echo strlen(bar) >> 2 >> >> Can this problem be taken care of using the change in encoding etc? >> Hmm... I see that >> :echo strlen(iconv(bar, &encoding, 'latin1')) >> 1 >> :echo strlen(substitute(bar, '.', 'x', 'g')) >> 1 >> >> So those two methods might work... It will be a definite improvement >> over the current "hack". Well, the idea is for :call IMAP(fb, "foo<++>bar") to return something like "foobar\<Esc>3\<bs>a". That should work for this example, but what if "bar" is replaced by something with a bunch of "\n" characters in it? One of the advantages of imap.vim--it respects auto-indent--makes it (nearly) impossible for us to compute how many spaces to back up. Back to the drawing board! My latest idea is to break up the RHS (in the example above) into "foo" and "" and "bar" and then to have IMAP_PutTextWithMovement() return something like "foo\<Esc>:call IMAP_YAHF(0)\<CR><++>bar\<Esc>:call IMAP_YAHF(1)\<CR>" and then call IMAP_Jumpfunc(). I will choose a more descriptive name than YAHF (Yet Another Helper Function), which will store the line and column number in a script-local variable (when called with argument 0) and then position the cursor there (when called with argument 1). Does anyone see any problems with this approach? Any objections (other than the profusion of helper functions)? --Benji |
From: Srinath A. <sr...@fa...> - 2003-01-06 19:31:01
|
On Mon, 6 Jan 2003, Benji Fisher wrote: > My latest idea is to break up the RHS (in the example above) into > "foo" and "" and "bar" and then to have IMAP_PutTextWithMovement() > return something like > > "foo\<Esc>:call IMAP_YAHF(0)\<CR><++>bar\<Esc>:call IMAP_YAHF(1)\<CR>" > Sounds like an excellent idea! I would suggest using something like "\<C-r>=IMAP_YAHF(0)\<CR>" instead of "\<Esc>:call IMAP_YAHF(0)\<CR>" because the former doesn't screw up the cursor positioning and moreover we remain in insert mode... (IMAP_YAHF(0) could just return '' always, but internally mark the cursor position in s:lastPosition. IMAP_YAHF(1) could return "\<C-o>".s:lastPosition) As the abve string stands, by the time we return from IMAP_YAHF(0), we are in escape mode and the bar is typed in normal mode... I am sure this was just a prototype and you would have used this anyway, but just putting my word in :) > Does anyone see any problems with this approach? Any objections > (other than the profusion of helper functions)? > No objections. I think this will solve those placement problems in a mathematically correct manner :) Srinath |
From: Benji F. <be...@me...> - 2003-01-07 18:36:29
|
Srinath Avadhanula wrote: > On Mon, 6 Jan 2003, Benji Fisher wrote: > > >> My latest idea is to break up the RHS (in the example above) into >> "foo" and "" and "bar" and then to have IMAP_PutTextWithMovement() >> return something like >> >> "foo\<Esc>:call IMAP_YAHF(0)\<CR><++>bar\<Esc>:call >> IMAP_YAHF(1)\<CR>" > > Sounds like an excellent idea! > > I would suggest using something like "\<C-r>=IMAP_YAHF(0)\<CR>" > instead of "\<Esc>:call IMAP_YAHF(0)\<CR>" because the former doesn't > screw up the cursor positioning and moreover we remain in insert > mode... (IMAP_YAHF(0) could just return '' always, but internally > mark the cursor position in s:lastPosition. IMAP_YAHF(1) could return > "\<C-o>".s:lastPosition) As the abve string stands, by the time we > return from IMAP_YAHF(0), we are in escape mode and the bar is typed > in normal mode... I am sure this was just a prototype and you would > have used this anyway, but just putting my word in :) I got something that seems to work, but not exactly as you suggested. I called the new helper function IMAP_Mark(). I need to get some work done, so I cannot test this as much as I would like. --Benji |
From: Srinath A. <sr...@fa...> - 2002-12-28 00:22:26
|
I apologize for these really screwed up commits. But fear not, I have repaired the cvs repository itself... version 1.15 of imaps.vim no longer exists. On Fri, 27 Dec 2002 sri...@us... wrote: > Update of /cvsroot/vim-latex/vimfiles/plugin > In directory sc8-pr-cvs1:/tmp/cvs-serv887 > > Modified Files: > imaps.vim > Log Message: > . changes from the b-newpackages branch... > > > Index: imaps.vim > =================================================================== > RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v > retrieving revision 1.14 > retrieving revision 1.15 > diff -C2 -d -r1.14 -r1.15 > *** imaps.vim 24 Dec 2002 12:51:06 -0000 1.14 > --- imaps.vim 27 Dec 2002 22:42:50 -0000 1.15 > *************** > *** 8,12 **** > " while preserving filetype indentation. > " > ! " Last Change: Tue Dec 24 04:00 AM 2002 PST > " > " Documentation: {{{ > --- 8,12 ---- > " while preserving filetype indentation. > " > ! " Last Change: Fri Dec 27 02:00 PM 2002 PST > " > " Documentation: {{{ > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Vim-latex-cvs mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vim-latex-cvs > > |