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 #29 received at 56210 <at> debbugs.gnu.org (full text, mbox):

From: Richard Hansen <rhansen <at> rhansen.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 56210 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#56210: 29.0.50; Keyboard macros do not trigger
 after-change-functions
Date: Mon, 27 Jun 2022 12:52:17 -0400
[Message part 1 (text/plain, inline)]
On 2022-06-27 03:50, Lars Ingebrigtsen wrote:
> does the same thing happen if you execute a keyboard macro 
> interactively?

That works.  Evaluating the following in *scratch* does not signal an error:

    (let* ((acf 0)
           (incacf (lambda (&rest _) (setq acf (1+ acf)))))
      (add-hook 'after-change-functions incacf nil t)
      (unwind-protect
          (execute-kbd-macro (kbd "x"))
        (remove-hook 'after-change-functions incacf t))
      (when (/= acf 1) (error "a-c-f didn't run")))

The above code shows that the hook runs synchronously as expected.  (The hook runs before `execute-kbd-macro' returns, not after some idle time or when execution returns to the main command loop.)

> Or if you run the same code outside of an ert context?
It does not work.  Evaluating the following in *scratch* signals an error:

    (save-window-excursion
      (with-temp-buffer
        (let ((b (current-buffer)))
          (with-current-buffer-window b
              `(display-buffer-below-selected
                (body-function
                 . ,(lambda (window)
                      (select-window window t)
                      (let ((acf 0))
                        (add-hook 'after-change-functions
                                  (lambda (&rest _) (setq acf (1+ acf)))
                                  nil t)
                        (execute-kbd-macro (kbd "x"))
                        (when (/= acf 1) (error "a-c-f didn't run"))))))
              nil))))
[OpenPGP_signature (application/pgp-signature, attachment)]

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.