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: Sun, 26 Jun 2022 23:21:24 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 2022-06-26 04:10, Eli Zaretskii wrote:
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?

Yes on both accounts.  See updated test below.

I changed the test to switch to the temporary buffer in the selected window and it now 
reliably inserts "x" into the temporary buffer.  It still doesn't run the 
`after-change-functions' hook, however.  Updated test code:

;; -*- lexical-binding: t; -*-
(require 'ert)
(require 'ert-x)
(defvar-local acf 0)
(defun acf (&rest _) (setq-local acf (1+ acf)))
(ert-deftest test ()
  (ert-with-test-buffer ()
    (let ((b (current-buffer)))
      (save-window-excursion
        (with-current-buffer-window b
            `(display-buffer-below-selected
              (body-function
               . ,(lambda (window)
                    (select-window window t)
                    (should (eq (current-buffer) b))
                    (setq-local acf 0)
                    ;; Note that LOCAL is t:
                    (add-hook 'after-change-functions #'acf nil t)
                    (should (memq #'acf after-change-functions))
                    (execute-kbd-macro (kbd "x"))
                    (should (equal (buffer-string) "x"))
                    ;; The above checks pass, this check fails:
                    (should (equal acf 1)))))
            nil)))))

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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