unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Hansen <rhansen@rhansen.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 56210@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: bug#56210: 29.0.50; Keyboard macros do not trigger after-change-functions
Date: Mon, 27 Jun 2022 12:52:17 -0400	[thread overview]
Message-ID: <cd692681-24d7-4b3d-749c-faaad33840cc@rhansen.org> (raw)
In-Reply-To: <87mtdy8rz9.fsf@gnus.org>


[-- Attachment #1.1: Type: text/plain, Size: 1541 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-06-27 16:52 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 [this message]
2022-06-27 16:54             ` Eli Zaretskii
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=cd692681-24d7-4b3d-749c-faaad33840cc@rhansen.org \
    --to=rhansen@rhansen.org \
    --cc=56210@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.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).