From: Eli Zaretskii Date: Fri, 10 Feb 2017 08:57:41 +0000 (+0200) Subject: Restore special setting of this-command-keys by M-x X-Git-Tag: emacs-26.0.90~848^2~10 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=937bf04804246c86a4b1bd55b506169f5a894e3b;p=emacs.git Restore special setting of this-command-keys by M-x It was lost when execute-extended-command was reimplemented in Lisp. * src/keyboard.c (Fset__this_command_keys): New function. (syms_of_keyboard): Defsubr it. * lisp/simple.el (execute-extended-command): Set this-command-keys as novice.el expects. (Bug#25612) --- diff --git a/lisp/simple.el b/lisp/simple.el index 441713a18b8..c0dad2d36e7 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1733,6 +1733,9 @@ invoking, give a prefix argument to `execute-extended-command'." (where-is-internal function overriding-local-map t)))) (unless (commandp function) (error "`%s' is not a valid command name" command-name)) + ;; Some features, such as novice.el, rely on this-command-keys + ;; including M-x COMMAND-NAME RET. + (set--this-command-keys (concat "\M-x" (symbol-name function) "\r")) (setq this-command function) ;; Normally `real-this-command' should never be changed, but here we really ;; want to pretend that M-x RET is nothing more than a "key diff --git a/src/keyboard.c b/src/keyboard.c index a86e7c5f8e4..168232203fe 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10001,6 +10001,30 @@ See also `this-command-keys-vector'. */) XVECTOR (this_command_keys)->contents); } +DEFUN ("set--this-command-keys", Fset__this_command_keys, + Sset__this_command_keys, 1, 1, 0, + doc: /* Set the vector to be returned by `this-command-keys'. +The argument KEYS must be a string. +Internal use only. */) + (Lisp_Object keys) +{ + CHECK_STRING (keys); + + this_command_key_count = 0; + this_single_command_key_start = 0; + int key0 = SREF (keys, 0); + + /* Kludge alert: this makes M-x be in the form expected by + novice.el. Any better ideas? */ + if (key0 == 248) + add_command_key (make_number ('x' | meta_modifier)); + else + add_command_key (make_number (key0)); + for (int i = 1; i < SCHARS (keys); i++) + add_command_key (make_number (SREF (keys, i))); + return Qnil; +} + DEFUN ("this-command-keys-vector", Fthis_command_keys_vector, Sthis_command_keys_vector, 0, 0, 0, doc: /* Return the key sequence that invoked this command, as a vector. However, if the command has called `read-key-sequence', it returns @@ -11211,6 +11235,7 @@ syms_of_keyboard (void) defsubr (&Sthis_command_keys_vector); defsubr (&Sthis_single_command_keys); defsubr (&Sthis_single_command_raw_keys); + defsubr (&Sset__this_command_keys); defsubr (&Sclear_this_command_keys); defsubr (&Ssuspend_emacs); defsubr (&Sabort_recursive_edit);