[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2523668: Add a new recursively bound `current-minibuffer-command'
From: |
Lars Ingebrigtsen |
Subject: |
master 2523668: Add a new recursively bound `current-minibuffer-command' variable |
Date: |
Mon, 14 Dec 2020 10:44:09 -0500 (EST) |
branch: master
commit 252366866b5691965c8c752aa103ab157a6f3aaa
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add a new recursively bound `current-minibuffer-command' variable
* doc/lispref/commands.texi (Command Loop Info): Document it
(bug#45177).
* src/callint.c (Fcall_interactively): Bind it.
* src/keyboard.c (syms_of_keyboard): Define
current-minibuffer-command.
---
doc/lispref/commands.texi | 7 +++++++
etc/NEWS | 6 ++++++
src/callint.c | 5 +++++
src/keyboard.c | 7 +++++++
4 files changed, 25 insertions(+)
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index ebfda01..15d7e4e 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -928,6 +928,13 @@ remapping), and @code{this-original-command} gives the
command that
was specified to run but remapped into another command.
@end defvar
+@defvar current-minibuffer-command
+This has the same value as @code{this-command}, but is bound
+recursively when entering a minibuffer. This variable can be used
+from minibuffer hooks and the like to determine what command opened
+the current minibuffer session.
+@end defvar
+
@defun this-command-keys
This function returns a string or vector containing the key sequence
that invoked the present command. Any events read by the command
diff --git a/etc/NEWS b/etc/NEWS
index 635da2d..a5e2c9c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1438,6 +1438,12 @@ that makes it a valid button.
** Miscellaneous
+++
+
+*** New variable 'current-minibuffer-command'.
+This is like 'this-command', but is bound recursively when entering
+the minibuffer.
+
++++
*** New function 'object-intervals'.
This function returns a copy of the list of intervals (i.e., text
properties) in the object in question (which must either be a string
diff --git a/src/callint.c b/src/callint.c
index f80436f..a221705 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -283,6 +283,11 @@ invoke it (via an `interactive' spec that contains, for
instance, an
Lisp_Object save_real_this_command = Vreal_this_command;
Lisp_Object save_last_command = KVAR (current_kboard, Vlast_command);
+ /* Bound recursively so that code can check the current command from
+ code running from minibuffer hooks (and the like), without being
+ overwritten by subsequent minibuffer calls. */
+ specbind (Qcurrent_minibuffer_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 dbca5be..54232aa 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11830,6 +11830,13 @@ will be in `last-command' during the following
command. */);
doc: /* This is like `this-command', except that commands should
never modify it. */);
Vreal_this_command = Qnil;
+ DEFSYM (Qcurrent_minibuffer_command, "current-minibuffer-command");
+ DEFVAR_LISP ("current-minibuffer-command", Vcurrent_minibuffer_command,
+ doc: /* This is like `this-command', but bound recursively.
+Code running from (for instance) a minibuffer hook can check this variable
+to see what command invoked the current minibuffer. */);
+ Vcurrent_minibuffer_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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2523668: Add a new recursively bound `current-minibuffer-command' variable,
Lars Ingebrigtsen <=