Subject: Re: bug#46982: 28.0.50; after-change-functions in an indirect buffer are not called if the change is done while base buffer is active (and vice versa)

From: Stefan Monnier <[email-masked]>
Date: Thu, 16 Jun 2022 22:36:29 -0400

> 1. emacs -Q
> 2. M-x clone-indirect-buffer <RET>
> 3. M-: (setq-local after-change-functions (append after-change-functions
>    '((lambda (&rest _) (message "Buffer 1"))))) <RET>
> 4. C-x o
> 5. M-: (setq-local after-change-functions (append after-change-functions
>    '((lambda (&rest _) (message "Buffer 2"))))) <RET>
> 6. Type something. "Buffer 2" message is displayed. "Buffer 1" message
>    is _not_ displayed.
> 7. C-x o
> 8. Type something. "Buffer 1" message is displayed. "Buffer 2" message
>    is _not_ displayed.

That's on purpose, yes.

> The current behaviour can potentially break major modes using
> after-change-functions if base buffer and indirect buffer do not have
> the same major mode.

It's currently the responsibility of the code that sets up the indirect
buffer(s) to setup a `before/after-change-functions` in the base buffer
that runs (some of) the `before/after-change-functions` in the indirect
buffer(s) where they are needed.

        Stefan