Subject: bug#45177: 27.1; Access to invoking top level command in minibuffer

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 13 Dec 2020 13:29:06 +0100

[email-masked] writes:

> I don't know anything about the C side of Emacs so I can't be of any
> help here.

I'm not quite sure where to bind the variable...  Does the following
work for you?

diff --git a/src/callint.c b/src/callint.c
index f80436f3d9..a01338dfe1 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -283,6 +283,8 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
   Lisp_Object save_real_this_command = Vreal_this_command;
   Lisp_Object save_last_command = KVAR (current_kboard, Vlast_command);
 
+  specbind (Qrecursive_this_command, Vreal_this_command);
+
   if (NILP (keys))
     keys = this_command_keys, key_count = this_command_key_count;
   else
diff --git a/src/keyboard.c b/src/keyboard.c
index dbca5be91e..ce2b7f1ef4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11830,6 +11830,11 @@ syms_of_keyboard (void)
 	       doc: /* This is like `this-command', except that commands should never modify it.  */);
   Vreal_this_command = Qnil;
 
+  DEFSYM (Qrecursive_this_command, "recursive-this-command");
+  DEFVAR_LISP ("recursive-this-command", Vrecursive_this_command,
+	       doc: /* This is like `real-this-command', but bound recursively in `call-interactively.  */);
+  Vrecursive_this_command = Qnil;
+
   DEFVAR_LISP ("this-command-keys-shift-translated",
 	       Vthis_command_keys_shift_translated,
 	       doc: /* Non-nil if the key sequence activating this command was shift-translated.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no