From: Eli Zaretskii <eliz@gnu.org>
To: Richard Hansen <rhansen@rhansen.org>
Cc: 56210@debbugs.gnu.org, larsi@gnus.org
Subject: bug#56210: 29.0.50; Keyboard macros do not trigger after-change-functions
Date: Mon, 27 Jun 2022 19:54:36 +0300 [thread overview]
Message-ID: <831qva82sz.fsf@gnu.org> (raw)
In-Reply-To: <70bed502-1c51-8cd6-68b1-16c4e3c410e0@rhansen.org> (message from Richard Hansen on Sun, 26 Jun 2022 23:21:24 -0400)
> Date: Sun, 26 Jun 2022 23:21:24 -0400
> Cc: larsi@gnus.org, 56210@debbugs.gnu.org
> From: Richard Hansen <rhansen@rhansen.org>
>
> > 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)))))
Your test calls with-current-buffer-window, which calls
temp-buffer-window-setup, which inhibits modification hooks:
(defun temp-buffer-window-setup (buffer-or-name)
"Set up temporary buffer specified by BUFFER-OR-NAME.
Return the buffer."
(let ((old-dir default-directory)
(buffer (get-buffer-create buffer-or-name)))
(with-current-buffer buffer
(kill-all-local-variables)
(setq default-directory old-dir)
(delete-all-overlays)
(setq buffer-read-only nil)
(setq buffer-file-name nil)
(setq buffer-undo-list t)
(let ((inhibit-read-only t)
(inhibit-modification-hooks t)) <<<<<<<<<<<<<<<<<<<<<<
(erase-buffer)
(run-hooks 'temp-buffer-window-setup-hook))
;; Return the buffer.
buffer)))
next prev parent reply other threads:[~2022-06-27 16:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-25 6:21 bug#56210: 29.0.50; Keyboard macros do not trigger after-change-functions Richard Hansen
2022-06-25 11:51 ` Lars Ingebrigtsen
2022-06-25 18:06 ` Richard Hansen
2022-06-25 18:56 ` Eli Zaretskii
2022-06-25 20:34 ` Richard Hansen
2022-06-26 8:10 ` Eli Zaretskii
2022-06-27 3:21 ` Richard Hansen
2022-06-27 7:50 ` Lars Ingebrigtsen
2022-06-27 16:52 ` Richard Hansen
2022-06-27 16:54 ` Eli Zaretskii [this message]
2022-06-27 17:07 ` Richard Hansen
2022-06-27 17:17 ` Eli Zaretskii
2022-06-27 17:22 ` Richard Hansen
2022-06-28 11:31 ` Lars Ingebrigtsen
2022-06-28 12:20 ` Eli Zaretskii
2022-06-28 12:26 ` Lars Ingebrigtsen
2022-06-27 17:23 ` Richard Hansen
2022-06-29 23:17 ` Richard Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=831qva82sz.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=56210@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=rhansen@rhansen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).