Brad Beveridge wrote:

> <SNIP> >
> > > Q1) Is using ml_append from (effectively) within RealWaitForChar a bad
> > > thing?  At the moment it appears to work properly.
> >
> > Yes.  You never know where in Vim you are, the caller may not handle the
> > situation that the text changes unexpectedly.  It's similar to
> > autocommands, which have caused crashes in the past.
>
> At what level in the stack is it safe to call ml_append, etc?  How do
> I tell Vim to retreat up to that level, is there code that I can look
> at?  At the moment I'm trying to do it by adding to an entry to
> keymap.h:key_extra, pushing 3 bytes into buf in os_unix.c (just like
> the cursorhold), but I have no idea how to get right out into
> main_loop.

A problem was recently reported with CursorHold: a two-character command
is interrupted, because the K_CURSORHOLD is put in the typeahead buffer.
I currently don't know a good solution.  Doing the work at a lower level
has the problem that the caller of vgetc() may be confused, while putting
something in the input buffer has the problem just mentioned.  A
complicated way would be to check all places where vgetc() is
(indirectly) called and handle special keys there.  That should at least
work when something like a double quote was typed.

In your case, if you know exactly what is going to be done in the event
handler, you may do some things at a low level.  But for something like
the CursorHold event, which can do anything (including switching to
another buffer), this will not be acceptable.

-- 
hundred-and-one symptoms of being an internet addict:
249. You've forgotten what the outside looks like.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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    ///

Reply via email to