emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (insert ?\n) spuriously calls before-change-functions twice. Help!


From: Alan Mackenzie
Subject: Re: (insert ?\n) spuriously calls before-change-functions twice. Help!
Date: Wed, 6 Jan 2010 13:05:21 +0000
User-agent: Mutt/1.5.9i

Hi, Stefan,

On Tue, Jan 05, 2010 at 02:52:37PM -0500, Stefan Monnier wrote:
> > I think I've tracked down what's happening.  After inserting the ?\n (any
> > other character is just the same), Emacs clears any text properties from
> > the new character by calling set_properties.  This, in its turn, invokes
> > before-change-functions.  A more detailed call stack is:

> Sounds like a bug indeed.

> > There doesn't seem to be any system in where the two change hooks are
> > invoked.  For example, insert directly calls signal_after_change, yet not
> > signal_before_change; surely invocations of these should be paired.

> Agreed.  Patch very welcome,

I'll look at this.  It looks impractical to change the source to do this.
signal_after_change seems usually to be paired with modify_region or
prepare_to_modify_buffer.  But I'll certainly fix the current bug, and
check (as far as I can) for other circumstances it might happen.

> > For CC Mode, I will put in a test for two consecutive invocations of
> > before-change-functions without an after-change-functions between
> > them.  In such a case, I then ignore the second invocation.  I think.

> Even if we fix the bug, there can be any number of reasons why the two
> hooks may occasionally not be paired, .....

Really?  I would have thought they should be rigorously paired, without
any "recursive" invocations in-between (barring elisp code doing this
deliberately).

> .... so your hooks should be robust against such situations.  IOW it's
> best to try and avoid relying in the after-hook on info passed from the
> before hook.

Haven't we discussed this before at some time?  ;-)

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]