From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#56210: 29.0.50; Keyboard macros do not trigger after-change-functions Date: Sun, 26 Jun 2022 11:10:57 +0300 Message-ID: <83fsjralpq.fsf@gnu.org> References: <8735ftklkr.fsf@gnus.org> <83pmiwa7y3.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6834"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56210@debbugs.gnu.org, larsi@gnus.org To: Richard Hansen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 26 10:12:13 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o5NNM-0001ai-0C for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 10:12:12 +0200 Original-Received: from localhost ([::1]:56928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5NNK-00043M-I8 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jun 2022 04:12:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5NNC-00043E-Rt for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 04:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5NNC-0007ZZ-Hm for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 04:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o5NNC-0005s0-Da for bug-gnu-emacs@gnu.org; Sun, 26 Jun 2022 04:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jun 2022 08:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56210 X-GNU-PR-Package: emacs Original-Received: via spool by 56210-submit@debbugs.gnu.org id=B56210.165623107022489 (code B ref 56210); Sun, 26 Jun 2022 08:12:02 +0000 Original-Received: (at 56210) by debbugs.gnu.org; 26 Jun 2022 08:11:10 +0000 Original-Received: from localhost ([127.0.0.1]:46659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5NMM-0005qf-Hp for submit@debbugs.gnu.org; Sun, 26 Jun 2022 04:11:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56272) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5NMI-0005q7-2E for 56210@debbugs.gnu.org; Sun, 26 Jun 2022 04:11:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5NMC-0007Th-6A; Sun, 26 Jun 2022 04:11:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=IwHSpSwmsoqCTW0nFjYt8AaKcyBtG7uEKjjJXqFeTQ0=; b=rvE+qWeUKLMJ piSUyht21nwxx1L7gKO5UQlfP1C2D1qn8RHWByPVezT1ulOznvhB5u2hUpMSx7U6RZw7QLWGS8cNr EOBxQKqOALVy0c8zOefS58wOamZf/Y5RaszEER6xpv+3AnRNcHmVH5e0vfWOz3BKUwxefB/JTgbbx wnWHV9CquFvm2TdthUWna3/+DkrQOfRIYH+kKVgSssbqOyDKSWSLCOQBjA/y6uyLYJfpiVA7vdFJ2 akR2Cggctd75HokMC8coERbTevKyzrGoZTCTuM9ukmvr4vflIX0QInPVDGVGQx3UGme3NCKIyLPid Me6o7UO4G0IZnc0YZ/GI7w==; Original-Received: from [87.69.77.57] (port=2167 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5NMA-0001Oo-Om; Sun, 26 Jun 2022 04:10:59 -0400 In-Reply-To: (message from Richard Hansen on Sat, 25 Jun 2022 16:34:11 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235307 Archived-At: > Date: Sat, 25 Jun 2022 16:34:11 -0400 > Cc: larsi@gnus.org, 56210@debbugs.gnu.org > From: Richard Hansen > > On 2022-06-25 14:56, Eli Zaretskii wrote: > > Maybe we should step back and ask what do you think the below do? > > > > (execute-kbd-macro (kbd "x")) > > > > What is, in your mental model, the effect of the above in Emacs? > > I would expect that to be roughly equivalent to typing "x" on the physical keyboard, which would insert an event into some sort of event queue. (I'm not familiar enough with Emacs to know whether that queue is per-buffer, per-window, per-frame, per-terminal, per-process, or something else.) Under normal circumstances, the event would be dispatched to the buffer associated with the `selected-window' of the `selected-frame', and insert an "x". That is correct. > I think my understanding of "current buffer" is incorrect. My current mental model of `with-current-buffer' is that it behaves as if the window's associated buffer is briefly switched to the specified buffer (like "C-x b" does) except it doesn't actually go to the expense of rendering the other buffer in the window (or update the toolbar, etc.). Looking at the documentation of `set-window-buffer', that mental model appears to be wrong. Yes, with-temp-buffer doesn't associate the temporary buffer with the selected window. And execute-kbd-macro starts a command loop, which always makes sure the selected-window's buffer is current. > But if my mental model is wrong, why does my original code insert "x" into the temporary buffer? It is not due to something specific to `ert-with-test-buffer', because if I evaluate the following in *scratch* then I see the same behavior that Lars saw with `with-temp-buffer' (the "x" is inserted into *scratch*): > > (ert-with-test-buffer () (execute-kbd-macro (kbd "x"))) > > Maybe `ert-run-tests-batch-and-exit' is setting it up to more closely simulate a user interacting with Emacs? Or maybe the behavior is caused by batch mode? Could be, you will have to investigate what ERT does in those cases. Its macro complexity is above my pay grade. > 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?