aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-12-14 16:44:00 +0100
committerLars Ingebrigtsen2020-12-14 16:44:00 +0100
commit252366866b5691965c8c752aa103ab157a6f3aaa (patch)
treeb7a11dcc5f21fc0603186ae7ef5f1d81477100e9
parentf6454ad6cd0dba9ab7ebff9b2959c05a607442ed (diff)
downloademacs-252366866b5691965c8c752aa103ab157a6f3aaa.tar.gz
emacs-252366866b5691965c8c752aa103ab157a6f3aaa.zip
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.
-rw-r--r--doc/lispref/commands.texi7
-rw-r--r--etc/NEWS6
-rw-r--r--src/callint.c5
-rw-r--r--src/keyboard.c7
4 files changed, 25 insertions, 0 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index ebfda01671e..15d7e4e3a71 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
928was specified to run but remapped into another command. 928was specified to run but remapped into another command.
929@end defvar 929@end defvar
930 930
931@defvar current-minibuffer-command
932This has the same value as @code{this-command}, but is bound
933recursively when entering a minibuffer. This variable can be used
934from minibuffer hooks and the like to determine what command opened
935the current minibuffer session.
936@end defvar
937
931@defun this-command-keys 938@defun this-command-keys
932This function returns a string or vector containing the key sequence 939This function returns a string or vector containing the key sequence
933that invoked the present command. Any events read by the command 940that invoked the present command. Any events read by the command
diff --git a/etc/NEWS b/etc/NEWS
index 635da2d84ab..a5e2c9cf26a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1438,6 +1438,12 @@ that makes it a valid button.
1438** Miscellaneous 1438** Miscellaneous
1439 1439
1440+++ 1440+++
1441
1442*** New variable 'current-minibuffer-command'.
1443This is like 'this-command', but is bound recursively when entering
1444the minibuffer.
1445
1446+++
1441*** New function 'object-intervals'. 1447*** New function 'object-intervals'.
1442This function returns a copy of the list of intervals (i.e., text 1448This function returns a copy of the list of intervals (i.e., text
1443properties) in the object in question (which must either be a string 1449properties) in the object in question (which must either be a string
diff --git a/src/callint.c b/src/callint.c
index f80436f3d91..a221705f676 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -283,6 +283,11 @@ invoke it (via an `interactive' spec that contains, for instance, an
283 Lisp_Object save_real_this_command = Vreal_this_command; 283 Lisp_Object save_real_this_command = Vreal_this_command;
284 Lisp_Object save_last_command = KVAR (current_kboard, Vlast_command); 284 Lisp_Object save_last_command = KVAR (current_kboard, Vlast_command);
285 285
286 /* Bound recursively so that code can check the current command from
287 code running from minibuffer hooks (and the like), without being
288 overwritten by subsequent minibuffer calls. */
289 specbind (Qcurrent_minibuffer_command, Vreal_this_command);
290
286 if (NILP (keys)) 291 if (NILP (keys))
287 keys = this_command_keys, key_count = this_command_key_count; 292 keys = this_command_keys, key_count = this_command_key_count;
288 else 293 else
diff --git a/src/keyboard.c b/src/keyboard.c
index dbca5be91e4..54232aaea1e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -11830,6 +11830,13 @@ will be in `last-command' during the following command. */);
11830 doc: /* This is like `this-command', except that commands should never modify it. */); 11830 doc: /* This is like `this-command', except that commands should never modify it. */);
11831 Vreal_this_command = Qnil; 11831 Vreal_this_command = Qnil;
11832 11832
11833 DEFSYM (Qcurrent_minibuffer_command, "current-minibuffer-command");
11834 DEFVAR_LISP ("current-minibuffer-command", Vcurrent_minibuffer_command,
11835 doc: /* This is like `this-command', but bound recursively.
11836Code running from (for instance) a minibuffer hook can check this variable
11837to see what command invoked the current minibuffer. */);
11838 Vcurrent_minibuffer_command = Qnil;
11839
11833 DEFVAR_LISP ("this-command-keys-shift-translated", 11840 DEFVAR_LISP ("this-command-keys-shift-translated",
11834 Vthis_command_keys_shift_translated, 11841 Vthis_command_keys_shift_translated,
11835 doc: /* Non-nil if the key sequence activating this command was shift-translated. 11842 doc: /* Non-nil if the key sequence activating this command was shift-translated.