GNU bug report logs - #56210
29.0.50; Keyboard macros do not trigger after-change-functions

Previous Next

Package: emacs;

Reported by: Richard Hansen <rhansen <at> rhansen.org>

Date: Sat, 25 Jun 2022 06:23:02 UTC

Severity: normal

Found in version 29.0.50

Done: Richard Hansen <rhansen <at> rhansen.org>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 56210 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Richard Hansen <rhansen <at> rhansen.org>
Cc: 56210 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#56210: 29.0.50; Keyboard macros do not trigger
 after-change-functions
Date: Sun, 26 Jun 2022 11:10:57 +0300
> Date: Sat, 25 Jun 2022 16:34:11 -0400
> Cc: larsi <at> gnus.org, 56210 <at> debbugs.gnu.org
> From: Richard Hansen <rhansen <at> rhansen.org>
> 
> On 2022-06-25 14:56, Eli Zaretskii wrote:
> > Maybe we should step back and ask what do you think the below do?
> > 
> >    (execute-kbd-macro (kbd "x"))
> > 
> > What is, in your mental model, the effect of the above in Emacs?
> 
> I would expect that to be roughly equivalent to typing "x" on the physical keyboard, which would insert an event into some sort of event queue.  (I'm not familiar enough with Emacs to know whether that queue is per-buffer, per-window, per-frame, per-terminal, per-process, or something else.)  Under normal circumstances, the event would be dispatched to the buffer associated with the `selected-window' of the `selected-frame', and insert an "x".

That is correct.

> I think my understanding of "current buffer" is incorrect.  My current mental model of `with-current-buffer' is that it behaves as if the window's associated buffer is briefly switched to the specified buffer (like "C-x b" does) except it doesn't actually go to the expense of rendering the other buffer in the window (or update the toolbar, etc.).  Looking at the documentation of `set-window-buffer', that mental model appears to be wrong.

Yes, with-temp-buffer doesn't associate the temporary buffer with the
selected window.  And execute-kbd-macro starts a command loop, which
always makes sure the selected-window's buffer is current.

> But if my mental model is wrong, why does my original code insert "x" into the temporary buffer? It is not due to something specific to `ert-with-test-buffer', because if I evaluate the following in *scratch* then I see the same behavior that Lars saw with `with-temp-buffer' (the "x" is inserted into *scratch*):
> 
>      (ert-with-test-buffer () (execute-kbd-macro (kbd "x")))
> 
> Maybe `ert-run-tests-batch-and-exit' is setting it up to more closely simulate a user interacting with Emacs?  Or maybe the behavior is caused by batch mode?

Could be, you will have to investigate what ERT does in those cases.
Its macro complexity is above my pay grade.

> Regardless, given that the temporary buffer is modified in my original example, shouldn't `after-change-functions' run?

Is the temporary buffer indeed modified, and is the hook set in that
buffer?




This bug report was last modified 2 years and 329 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.