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

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

bug#56210: 29.0.50; Keyboard macros do not trigger after-change-function


From: Richard Hansen
Subject: bug#56210: 29.0.50; Keyboard macros do not trigger after-change-functions
Date: Mon, 27 Jun 2022 12:52:17 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

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))))

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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