bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#65451: 30.0.50; `after-change-functions' are not triggered in the sa


From: Stefan Monnier
Subject: bug#65451: 30.0.50; `after-change-functions' are not triggered in the same order the changes are made
Date: Sat, 30 Mar 2024 09:51:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> ⛔ Warning (emacs): Before: 1278 1281
>> ⛔ Warning (emacs): Before: 1278 1288
>> ⛔ Warning (emacs): After: 1278 1288 delta: 0
>> ⛔ Warning (emacs): After: 1278 1288 delta: 7
>> 
>> Note how "After: 1278 1288 delta: 0" reports a change of "utf-8-unix"
>> that did not alter the buffer text size. It is trigerred _before_
>> "After: 1278 1288 delta: 7" that corresponds to replacing "UTF" with
>> "utf-8-unix".

Hmm... yes, that's bad.  Alan, have you looked at this?

I suspect the best option in the above case is to inhibit the inner
calls to before/after (assuming we're sure they change only the "new
text"), so we'd be down to:

    ⛔ Warning (emacs): Before: 1278 1281
    ⛔ Warning (emacs): After: 1278 1288 delta: 7

> I think Org mode is relying on something it should not.  This
> particular use case aside, Emacs is allowed to call a function that
> changes the buffer from a function that itself changes the buffer, and
> it is allowed to call that inner function _before_ it did all the
> changes it intended to do.

AFAIK the above sequences breaks the promise we make about
`before-change-functions` and `after-change-functions`.

Almost all the non-trivial users of those hooks (i.e. basically those
that need to use both hooks) have extra sanity and raise the heads up in
despair when faced with things like the above (my `track-changes.el`
lacks such sanity checks, but that's because it's a PoC).


        Stefan






reply via email to

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