aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-06-02 15:21:34 -0400
committerStefan Monnier2012-06-02 15:21:34 -0400
commitf2d6a3df6ab288a909ad3dc9fcadfdb28e46f2ee (patch)
tree496b84ebd6cbe2bd04405dac1a3a951d82f6cb3d
parent7bd5c1f4a4abb97576a26d6b0a9691c5f530d99f (diff)
downloademacs-f2d6a3df6ab288a909ad3dc9fcadfdb28e46f2ee.tar.gz
emacs-f2d6a3df6ab288a909ad3dc9fcadfdb28e46f2ee.zip
* lisp/simple.el (execute-extended-command): Set real-this-command.
* src/keyboard.c: Export real-this-command to Elisp. (syms_of_keyboard): Rename real_this_command to Vreal_this_command and DEFVAR it. Update all users. Fixes: debbugs:11506
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el12
-rw-r--r--src/ChangeLog6
-rw-r--r--src/callint.c13
-rw-r--r--src/keyboard.c32
-rw-r--r--src/macros.c8
6 files changed, 47 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b973d09fc43..e39b8a64205 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-06-02 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * simple.el (execute-extended-command): Set real-this-command
4 (bug#11506).
5
12012-06-02 Chong Yidong <cyd@gnu.org> 62012-06-02 Chong Yidong <cyd@gnu.org>
2 7
3 Remove incorrect uses of "modeline" in comments, docstrings, and 8 Remove incorrect uses of "modeline" in comments, docstrings, and
diff --git a/lisp/simple.el b/lisp/simple.el
index 561d3656eb7..655298e4fea 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1378,13 +1378,17 @@ give to the command you invoke, if it asks for an argument."
1378 (if (null command-name) (setq command-name (read-extended-command))) 1378 (if (null command-name) (setq command-name (read-extended-command)))
1379 (let* ((function (and (stringp command-name) (intern-soft command-name))) 1379 (let* ((function (and (stringp command-name) (intern-soft command-name)))
1380 (binding (and suggest-key-bindings 1380 (binding (and suggest-key-bindings
1381 (not executing-kbd-macro) 1381 (not executing-kbd-macro)
1382 (where-is-internal function overriding-local-map t)))) 1382 (where-is-internal function overriding-local-map t))))
1383 (unless (commandp function) 1383 (unless (commandp function)
1384 (error "`%s' is not a valid command name" command-name)) 1384 (error "`%s' is not a valid command name" command-name))
1385 ;; Set this_command_keys to the concatenation of saved-keys and
1386 ;; function, followed by a RET.
1387 (setq this-command function) 1385 (setq this-command function)
1386 ;; Normally `real-this-command' should never be changed, but here we really
1387 ;; want to pretend that M-x <cmd> RET is nothing more than a "key
1388 ;; binding" for <cmd>, so the command the user really wanted to run is
1389 ;; `function' and not `execute-extended-command'. The difference is
1390 ;; visible in cases such as M-x <cmd> RET and then C-x z (bug#11506).
1391 (setq real-this-command function)
1388 (let ((prefix-arg prefixarg)) 1392 (let ((prefix-arg prefixarg))
1389 (command-execute function 'record)) 1393 (command-execute function 'record))
1390 ;; If enabled, show which key runs this command. 1394 ;; If enabled, show which key runs this command.
diff --git a/src/ChangeLog b/src/ChangeLog
index e5fddec94a4..ed808a39742 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12012-06-02 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * keyboard.c: Export real-this-command to Elisp.
4 (syms_of_keyboard): Rename real_this_command to Vreal_this_command
5 and DEFVAR it. Update all users.
6
12012-06-02 Paul Eggert <eggert@cs.ucla.edu> 72012-06-02 Paul Eggert <eggert@cs.ucla.edu>
2 8
3 * minibuf.c (Fassoc_string): Remove duplicate declaration. 9 * minibuf.c (Fassoc_string): Remove duplicate declaration.
diff --git a/src/callint.c b/src/callint.c
index 506698a4e4e..bfa981ec65a 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -284,7 +284,7 @@ invoke it. If KEYS is omitted or nil, the return value of
284 284
285 save_this_command = Vthis_command; 285 save_this_command = Vthis_command;
286 save_this_original_command = Vthis_original_command; 286 save_this_original_command = Vthis_original_command;
287 save_real_this_command = real_this_command; 287 save_real_this_command = Vreal_this_command;
288 save_last_command = KVAR (current_kboard, Vlast_command); 288 save_last_command = KVAR (current_kboard, Vlast_command);
289 289
290 if (NILP (keys)) 290 if (NILP (keys))
@@ -295,7 +295,7 @@ invoke it. If KEYS is omitted or nil, the return value of
295 key_count = ASIZE (keys); 295 key_count = ASIZE (keys);
296 } 296 }
297 297
298 /* Save this now, since use of minibuffer will clobber it. */ 298 /* Save this now, since use of minibuffer will clobber it. */
299 prefix_arg = Vcurrent_prefix_arg; 299 prefix_arg = Vcurrent_prefix_arg;
300 300
301 if (SYMBOLP (function)) 301 if (SYMBOLP (function))
@@ -310,7 +310,8 @@ invoke it. If KEYS is omitted or nil, the return value of
310 The feature is not fully implemented. */ 310 The feature is not fully implemented. */
311 filter_specs = Qnil; 311 filter_specs = Qnil;
312 312
313 /* If k or K discard an up-event, save it here so it can be retrieved with U */ 313 /* If k or K discard an up-event, save it here so it can be retrieved with
314 U. */
314 up_event = Qnil; 315 up_event = Qnil;
315 316
316 /* Set SPECS to the interactive form, or barf if not interactive. */ 317 /* Set SPECS to the interactive form, or barf if not interactive. */
@@ -370,14 +371,14 @@ invoke it. If KEYS is omitted or nil, the return value of
370 371
371 Vthis_command = save_this_command; 372 Vthis_command = save_this_command;
372 Vthis_original_command = save_this_original_command; 373 Vthis_original_command = save_this_original_command;
373 real_this_command= save_real_this_command; 374 Vreal_this_command = save_real_this_command;
374 KVAR (current_kboard, Vlast_command) = save_last_command; 375 KVAR (current_kboard, Vlast_command) = save_last_command;
375 376
376 temporarily_switch_to_single_kboard (NULL); 377 temporarily_switch_to_single_kboard (NULL);
377 return unbind_to (speccount, apply1 (function, specs)); 378 return unbind_to (speccount, apply1 (function, specs));
378 } 379 }
379 380
380 /* Here if function specifies a string to control parsing the defaults */ 381 /* Here if function specifies a string to control parsing the defaults. */
381 382
382 /* Set next_event to point to the first event with parameters. */ 383 /* Set next_event to point to the first event with parameters. */
383 for (next_event = 0; next_event < key_count; next_event++) 384 for (next_event = 0; next_event < key_count; next_event++)
@@ -841,7 +842,7 @@ invoke it. If KEYS is omitted or nil, the return value of
841 842
842 Vthis_command = save_this_command; 843 Vthis_command = save_this_command;
843 Vthis_original_command = save_this_original_command; 844 Vthis_original_command = save_this_original_command;
844 real_this_command= save_real_this_command; 845 Vreal_this_command = save_real_this_command;
845 KVAR (current_kboard, Vlast_command) = save_last_command; 846 KVAR (current_kboard, Vlast_command) = save_last_command;
846 847
847 { 848 {
diff --git a/src/keyboard.c b/src/keyboard.c
index 2642ad7734b..093e33ec67c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -217,9 +217,6 @@ uintmax_t num_input_events;
217 217
218static EMACS_INT last_auto_save; 218static EMACS_INT last_auto_save;
219 219
220/* This is like Vthis_command, except that commands never set it. */
221Lisp_Object real_this_command;
222
223/* The value of point when the last command was started. */ 220/* The value of point when the last command was started. */
224static ptrdiff_t last_point_position; 221static ptrdiff_t last_point_position;
225 222
@@ -1376,9 +1373,9 @@ command_loop_1 (void)
1376 1373
1377 /* Do this after running Vpost_command_hook, for consistency. */ 1374 /* Do this after running Vpost_command_hook, for consistency. */
1378 KVAR (current_kboard, Vlast_command) = Vthis_command; 1375 KVAR (current_kboard, Vlast_command) = Vthis_command;
1379 KVAR (current_kboard, Vreal_last_command) = real_this_command; 1376 KVAR (current_kboard, Vreal_last_command) = Vreal_this_command;
1380 if (!CONSP (last_command_event)) 1377 if (!CONSP (last_command_event))
1381 KVAR (current_kboard, Vlast_repeatable_command) = real_this_command; 1378 KVAR (current_kboard, Vlast_repeatable_command) = Vreal_this_command;
1382 1379
1383 while (1) 1380 while (1)
1384 { 1381 {
@@ -1445,7 +1442,7 @@ command_loop_1 (void)
1445 before_command_echo_length = echo_length (); 1442 before_command_echo_length = echo_length ();
1446 1443
1447 Vthis_command = Qnil; 1444 Vthis_command = Qnil;
1448 real_this_command = Qnil; 1445 Vreal_this_command = Qnil;
1449 Vthis_original_command = Qnil; 1446 Vthis_original_command = Qnil;
1450 Vthis_command_keys_shift_translated = Qnil; 1447 Vthis_command_keys_shift_translated = Qnil;
1451 1448
@@ -1529,7 +1526,7 @@ command_loop_1 (void)
1529 /* Execute the command. */ 1526 /* Execute the command. */
1530 1527
1531 Vthis_command = cmd; 1528 Vthis_command = cmd;
1532 real_this_command = cmd; 1529 Vreal_this_command = cmd;
1533 safe_run_hooks (Qpre_command_hook); 1530 safe_run_hooks (Qpre_command_hook);
1534 1531
1535 already_adjusted = 0; 1532 already_adjusted = 0;
@@ -1613,12 +1610,14 @@ command_loop_1 (void)
1613 If the command didn't actually create a prefix arg, 1610 If the command didn't actually create a prefix arg,
1614 but is merely a frame event that is transparent to prefix args, 1611 but is merely a frame event that is transparent to prefix args,
1615 then the above doesn't apply. */ 1612 then the above doesn't apply. */
1616 if (NILP (KVAR (current_kboard, Vprefix_arg)) || CONSP (last_command_event)) 1613 if (NILP (KVAR (current_kboard, Vprefix_arg))
1614 || CONSP (last_command_event))
1617 { 1615 {
1618 KVAR (current_kboard, Vlast_command) = Vthis_command; 1616 KVAR (current_kboard, Vlast_command) = Vthis_command;
1619 KVAR (current_kboard, Vreal_last_command) = real_this_command; 1617 KVAR (current_kboard, Vreal_last_command) = Vreal_this_command;
1620 if (!CONSP (last_command_event)) 1618 if (!CONSP (last_command_event))
1621 KVAR (current_kboard, Vlast_repeatable_command) = real_this_command; 1619 KVAR (current_kboard, Vlast_repeatable_command)
1620 = Vreal_this_command;
1622 cancel_echoing (); 1621 cancel_echoing ();
1623 this_command_key_count = 0; 1622 this_command_key_count = 0;
1624 this_command_key_count_reset = 0; 1623 this_command_key_count_reset = 0;
@@ -11472,9 +11471,6 @@ syms_of_keyboard (void)
11472 staticpro (&tool_bar_items_vector); 11471 staticpro (&tool_bar_items_vector);
11473 tool_bar_items_vector = Qnil; 11472 tool_bar_items_vector = Qnil;
11474 11473
11475 staticpro (&real_this_command);
11476 real_this_command = Qnil;
11477
11478 DEFSYM (Qtimer_event_handler, "timer-event-handler"); 11474 DEFSYM (Qtimer_event_handler, "timer-event-handler");
11479 DEFSYM (Qdisabled_command_function, "disabled-command-function"); 11475 DEFSYM (Qdisabled_command_function, "disabled-command-function");
11480 DEFSYM (Qself_insert_command, "self-insert-command"); 11476 DEFSYM (Qself_insert_command, "self-insert-command");
@@ -11728,12 +11724,14 @@ was a kill command.
11728See Info node `(elisp)Multiple Terminals'. */); 11724See Info node `(elisp)Multiple Terminals'. */);
11729 11725
11730 DEFVAR_KBOARD ("real-last-command", Vreal_last_command, 11726 DEFVAR_KBOARD ("real-last-command", Vreal_last_command,
11731 doc: /* Same as `last-command', but never altered by Lisp code. */); 11727 doc: /* Same as `last-command', but never altered by Lisp code.
11728Taken from the previous value of `real-this-command'. */);
11732 11729
11733 DEFVAR_KBOARD ("last-repeatable-command", Vlast_repeatable_command, 11730 DEFVAR_KBOARD ("last-repeatable-command", Vlast_repeatable_command,
11734 doc: /* Last command that may be repeated. 11731 doc: /* Last command that may be repeated.
11735The last command executed that was not bound to an input event. 11732The last command executed that was not bound to an input event.
11736This is the command `repeat' will try to repeat. */); 11733This is the command `repeat' will try to repeat.
11734Taken from a previous value of `real-this-command'. */);
11737 11735
11738 DEFVAR_LISP ("this-command", Vthis_command, 11736 DEFVAR_LISP ("this-command", Vthis_command,
11739 doc: /* The command now being executed. 11737 doc: /* The command now being executed.
@@ -11741,6 +11739,10 @@ The command can set this variable; whatever is put here
11741will be in `last-command' during the following command. */); 11739will be in `last-command' during the following command. */);
11742 Vthis_command = Qnil; 11740 Vthis_command = Qnil;
11743 11741
11742 DEFVAR_LISP ("real-this-command", Vreal_this_command,
11743 doc: /* This is like `this-command', except that commands should never modify it. */);
11744 Vreal_this_command = Qnil;
11745
11744 DEFVAR_LISP ("this-command-keys-shift-translated", 11746 DEFVAR_LISP ("this-command-keys-shift-translated",
11745 Vthis_command_keys_shift_translated, 11747 Vthis_command_keys_shift_translated,
11746 doc: /* Non-nil if the key sequence activating this command was shift-translated. 11748 doc: /* Non-nil if the key sequence activating this command was shift-translated.
diff --git a/src/macros.c b/src/macros.c
index 3f4f8624479..0db7e63d622 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -259,7 +259,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
259 from before this macro started. */ 259 from before this macro started. */
260 Vthis_command = KVAR (current_kboard, Vlast_command); 260 Vthis_command = KVAR (current_kboard, Vlast_command);
261 /* C-x z after the macro should repeat the macro. */ 261 /* C-x z after the macro should repeat the macro. */
262 real_this_command = KVAR (current_kboard, Vlast_kbd_macro); 262 Vreal_this_command = KVAR (current_kboard, Vlast_kbd_macro);
263 263
264 if (! NILP (KVAR (current_kboard, defining_kbd_macro))) 264 if (! NILP (KVAR (current_kboard, defining_kbd_macro)))
265 error ("Can't execute anonymous macro while defining one"); 265 error ("Can't execute anonymous macro while defining one");
@@ -286,7 +286,7 @@ pop_kbd_macro (Lisp_Object info)
286 Vexecuting_kbd_macro = XCAR (info); 286 Vexecuting_kbd_macro = XCAR (info);
287 tem = XCDR (info); 287 tem = XCDR (info);
288 executing_kbd_macro_index = XINT (XCAR (tem)); 288 executing_kbd_macro_index = XINT (XCAR (tem));
289 real_this_command = XCDR (tem); 289 Vreal_this_command = XCDR (tem);
290 Frun_hooks (1, &Qkbd_macro_termination_hook); 290 Frun_hooks (1, &Qkbd_macro_termination_hook);
291 return Qnil; 291 return Qnil;
292} 292}
@@ -321,7 +321,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
321 321
322 tem = Fcons (Vexecuting_kbd_macro, 322 tem = Fcons (Vexecuting_kbd_macro,
323 Fcons (make_number (executing_kbd_macro_index), 323 Fcons (make_number (executing_kbd_macro_index),
324 real_this_command)); 324 Vreal_this_command));
325 record_unwind_protect (pop_kbd_macro, tem); 325 record_unwind_protect (pop_kbd_macro, tem);
326 326
327 GCPRO2 (final, loopfunc); 327 GCPRO2 (final, loopfunc);
@@ -352,7 +352,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
352 352
353 executing_kbd_macro = Qnil; 353 executing_kbd_macro = Qnil;
354 354
355 real_this_command = Vexecuting_kbd_macro; 355 Vreal_this_command = Vexecuting_kbd_macro;
356 356
357 UNGCPRO; 357 UNGCPRO;
358 return unbind_to (pdlcount, Qnil); 358 return unbind_to (pdlcount, Qnil);