Subject: Re: bug#48603: 27.2; [PATCH] Quit minibuffers without aborting kmacros

From: <[email-masked]>
Date: Tue, 07 Sep 2021 17:11:11 +0200

Lars Ingebrigtsen <[email-masked]> writes:

> <[email-masked]> writes:
>
>> Good idea, attaching a revised patch (which also adds two NEWS entries.)
>
> Sorry; I forgot all about this.  I've now re-read and tested the patch,
> and it seems to work fine for me, so I've pushed it to Emacs 28.

After some testing, I found out that we can't record kmacros that end
with C-g in the minibuffer. For example, trying to record a kmacro like
"C-n M-x C-g" will actually record only "C-n".

Please consider the attached patch to fix this.

From 1fc801cde2cd0a7c557fdb3d4e1593eaa85518f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <[email-masked]>
Date: Tue, 7 Sep 2021 16:55:22 +0200
Subject: [PATCH] Allow kmacros to end with C-g in minibuffer

* src/keyboard.c (cmd_error): If a command causes a minibuffer-quit
condition, record its key in a keyboard macro.
---
 src/keyboard.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/keyboard.c b/src/keyboard.c
index f6139b30e7..a32c3e7b2b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -951,6 +951,10 @@ cmd_error (Lisp_Object data)
       Vexecuting_kbd_macro = Qnil;
       executing_kbd_macro = Qnil;
     }
+  else if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
+    /* A command that signals a minibuffer-quit condition should be
+       installed in kbd macro.  */
+    finalize_kbd_macro_chars ();
 
   specbind (Qstandard_output, Qt);
   specbind (Qstandard_input, Qt);
-- 
2.33.0