Benjamin Haskell wrote:

> On Tue, 6 Jul 2010, Tony Mechelynck wrote:
> 
> > Forward to list.
> > 
> > -------- Original Message --------
> > Subject: Re: synstack() in insert mode
> > Date: Tue, 6 Jul 2010 05:59:18 +0100
> > From: Marcin Szamotulski <msza...@gmail.com>
> > To: Tony Mechelynck <antoine.mechely...@gmail.com>
> > 
> > On 04:09 Tue 06 Jul     , Tony Mechelynck wrote:
> > > On 06/07/10 02:13, Marcin Szamotulski wrote:
> > > >
> > > > Sorry for not being precise, this doesn't give an error, but 
> > > > g:synstack variable should be a list while if I do ':echo 
> > > > g:synstack' I get '0' not '[]'.
> > > >
> > > > In a script I'm getting error because I then process with 
> > > > g:synstack as a list.
> > > >
> > > > Best regards,
> > > > Marcin
> > > 
> > > Well, I get the value [] in g:synstack.
> > > 
> > > Also, please remember that bottom-posting is preferred on this list, 
> > > as mentioned until two and a half hours ago at the very bottom of 
> > > every post.
> > > 
> > 
> > In both gentoo distributed version of vim and fresh install (using svn)
> > I get an error while in empty line, in non empty line things works fine.
> > 
> 
> Using Tony's example autocmd:
> :set cmdheight=2
> :aug testing
> :au!
> :au CursorMovedI * echo synstack(line('.'),col('.'))
> :aug END
> I get an empty value (not []) when the cursor is at the end of the line.
> 
> E.g. with ft=sql, enter insert mode and use the arrow keys to move.  
> Cursor position marked with '^' below, and the output of the autocmd.  
> There's no trailing space on the line.
> 
> select * from
>       ^ - []
> select * from
>             ^ - [108]
> select * from
>              ^ - blank
> 
> Changing the autocmd to need a list, I get 'List required' errors:
> 
> e.g.:
> :aug testing
> :au!
> :au CursorMovedI * let l=synstack(line('.'),col('.')) | for x in l | echo "," 
> l | endfor
> :aug END
> 
> For the OP: The workaround is probably to change whatever is setting 
> g:synstack 
> to check for an index beyond the end of the line:
> 
> " off the cuff -- probably wrong for multibyte encodings...
> if col('.') > strlen(getline('.'))
>    let g:synstack = []
> else
>    let g:synstack = synstack(line('.'),col('.'))
> endif

I'll make it so that synstack() works when on the character just after
the end of the line.  It was already working for an empty line, thus
should also work when just after the last character.

-- 
       He was not in the least bit scared to be mashed into a pulp
       Or to have his eyes gouged out and his elbows broken;
       To have his kneecaps split and his body burned away
       And his limbs all hacked and mangled, brave Sir Robin.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to