aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-10-03 09:17:37 +0000
committerRichard M. Stallman1995-10-03 09:17:37 +0000
commit6526ab49f0ca100f0166f42a6d288366820dc575 (patch)
tree9e3d3b01eaf7f3fa9d9a117318c9c64eec761217 /src
parent68db017386579f2c100e606df13934378286271e (diff)
downloademacs-6526ab49f0ca100f0166f42a6d288366820dc575.tar.gz
emacs-6526ab49f0ca100f0166f42a6d288366820dc575.zip
(Vsuggest_key_bindings): New variable.
(syms_of_keyboard): Set up Lisp variable. (Fexecute_extended_command): When enabled, show an equivalent key binding.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index b4401f4fd62..23ab91f9745 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -172,6 +172,12 @@ Lisp_Object Vprefix_help_command;
172/* List of items that should move to the end of the menu bar. */ 172/* List of items that should move to the end of the menu bar. */
173Lisp_Object Vmenu_bar_final_items; 173Lisp_Object Vmenu_bar_final_items;
174 174
175/* Non-nil means show the equivalent key-binding for
176 any M-x command that has one.
177 The value can be a length of time to show the message for.
178 If the value is non-nil and not a number, we wait 2 seconds. */
179Lisp_Object Vsuggest_key_bindings;
180
175/* Character that causes a quit. Normally C-g. 181/* Character that causes a quit. Normally C-g.
176 182
177 If we are running on an ordinary terminal, this must be an ordinary 183 If we are running on an ordinary terminal, this must be an ordinary
@@ -6367,8 +6373,75 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
6367 current_kboard->Vprefix_arg = prefixarg; 6373 current_kboard->Vprefix_arg = prefixarg;
6368 this_command = function; 6374 this_command = function;
6369 6375
6376 /* If enabled, show which key runs this command. */
6377 if (!NILP (Vsuggest_key_bindings)
6378 && SYMBOLP (function))
6379 {
6380 Lisp_Object *maps, bindings;
6381 int nmaps, i;
6382
6383 bindings = Qnil;
6384 nmaps = current_active_maps (&maps);
6385
6386 for (i = 0; i < nmaps && NILP (bindings); i++)
6387 bindings = Fwhere_is_internal (function, maps[i], Qt, Qnil);
6388
6389 free (maps);
6390
6391 if (!NILP (bindings))
6392 {
6393 message ("You can run the command `%s' by typing %s",
6394 XSYMBOL (function)->name->data,
6395 XSTRING (Fkey_description (bindings))->data);
6396 Fsit_for ((NUMBERP (Vsuggest_key_bindings)
6397 ? Vsuggest_key_bindings : make_number (2)),
6398 Qnil, Qnil);
6399 }
6400 }
6401
6370 return Fcommand_execute (function, Qt); 6402 return Fcommand_execute (function, Qt);
6371} 6403}
6404
6405/* Find the set of keymaps now active.
6406 Store into *MAPS_P a vector holding the various maps
6407 and return the number of them. The vector was malloc'd
6408 and the caller should free it. */
6409
6410int
6411current_active_maps (maps_p)
6412 Lisp_Object **maps_p;
6413{
6414 Lisp_Object *tmaps, *maps;
6415 int nmaps;
6416
6417 /* Should overriding-terminal-local-map and overriding-local-map apply? */
6418 if (!NILP (Voverriding_local_map_menu_flag))
6419 {
6420 /* Yes, use them (if non-nil) as well as the global map. */
6421 maps = (Lisp_Object *) xmalloc (3 * sizeof (maps[0]));
6422 nmaps = 0;
6423 if (!NILP (current_kboard->Voverriding_terminal_local_map))
6424 maps[nmaps++] = current_kboard->Voverriding_terminal_local_map;
6425 if (!NILP (Voverriding_local_map))
6426 maps[nmaps++] = Voverriding_local_map;
6427 }
6428 else
6429 {
6430 /* No, so use major and minor mode keymaps. */
6431 nmaps = current_minor_maps (NULL, &tmaps);
6432 maps = (Lisp_Object *) xmalloc ((nmaps + 2) * sizeof (maps[0]));
6433 bcopy (tmaps, maps, nmaps * sizeof (maps[0]));
6434#ifdef USE_TEXT_PROPERTIES
6435 maps[nmaps++] = get_local_map (PT, current_buffer);
6436#else
6437 maps[nmaps++] = current_buffer->keymap;
6438#endif
6439 }
6440 maps[nmaps++] = current_global_map;
6441
6442 *maps_p = maps;
6443 return nmaps;
6444}
6372 6445
6373 6446
6374detect_input_pending () 6447detect_input_pending ()
@@ -7407,6 +7480,12 @@ The precise format isn't relevant here; we just check whether it is nil.");
7407This function is called with no arguments after each command\n\ 7480This function is called with no arguments after each command\n\
7408whenever `deferred-action-list' is non-nil."); 7481whenever `deferred-action-list' is non-nil.");
7409 Vdeferred_action_function = Qnil; 7482 Vdeferred_action_function = Qnil;
7483
7484 DEFVAR_LISP ("suggest-key-bindings", &Vsuggest_key_bindings,
7485 "Non-nil means show the equivalent key-binding when M-x command has one.\n\
7486The value can be a length of time to show the message for.\n\
7487If the value is non-nil and not a number, we wait 2 seconds.");
7488 Vsuggest_key_bindings = Qt;
7410} 7489}
7411 7490
7412keys_of_keyboard () 7491keys_of_keyboard ()