all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: (insert ?\n) spuriously calls before-change-functions twice. Help!
Date: Wed, 6 Jan 2010 13:05:21 +0000	[thread overview]
Message-ID: <20100106130521.GA2447@muc.de> (raw)
In-Reply-To: <jwv1vi4l4ef.fsf-monnier+emacs@gnu.org>

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	other threads:[~2010-01-06 13:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05 11:09 (insert ?\n) spuriously calls before-change-functions twice. Help! Alan Mackenzie
2010-01-05 15:22 ` Stefan Monnier
2010-01-05 17:31   ` Alan Mackenzie
2010-01-05 19:52     ` Stefan Monnier
2010-01-06 13:05       ` Alan Mackenzie [this message]
2010-01-06 14:33         ` Stefan Monnier
2010-01-19 13:23       ` Alan Mackenzie
2010-01-19 15:11         ` Chong Yidong
2010-01-19 17:11           ` Alan Mackenzie
2010-01-19 18:02             ` Chong Yidong
2010-01-19 22:30               ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100106130521.GA2447@muc.de \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.