Subject: bug#65451: 30.0.50; `after-change-functions' are not triggered in the same order the changes are made

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Mar 2024 17:11:02 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: Ihor Radchenko <[email-masked]>,  [email-masked], Alan
>  Mackenzie <[email-masked]>
> Date: Sat, 30 Mar 2024 09:51:59 -0400
> 
> > 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).

I still stand by my opinion: Org is relying on something it cannot
rely upon, not as long as a function that changes a buffer can be
called from another function which changes the same buffer.  I don't
see how we can avoid breaking code which relies on such assumptions,
not in general anyway.