From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: 25612@debbugs.gnu.org
Subject: bug#25612: 26.0.50; Slightly suboptimal message for disabled commands
Date: Fri, 03 Feb 2017 23:16:27 +0200 [thread overview]
Message-ID: <83vasrt1p0.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkTppyxosR0fByMKq=W+fUxKzKs+YJxZ1DKdqEwv4vPJgw@mail.gmail.com> (message from Philipp Stephani on Fri, 03 Feb 2017 15:54:06 +0000)
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Fri, 03 Feb 2017 15:54:06 +0000
> Cc: 25612@debbugs.gnu.org
>
> Yes, this-command-keys returns just "^M" instead of the expected
> "\370erase-buffer^M" it returned in Emacs 24.2 and older.
>
> git bisect says
>
> b593d6a999b21dfee6939b24866a5ec6fbe7d11b is the first bad commit
> commit b593d6a999b21dfee6939b24866a5ec6fbe7d11b
> Author: Aaron S. Hawley <aaron.s.hawley@gmail.com>
> Date: Tue May 1 12:10:02 2012 -0400
>
> Reimplement execute-extended-command in Elisp.
> * src/keyboard.c (Fexecute_extended_command, Vsuggest_key_bindings):
> Move to simple.el.
> * lisp/simple.el (suggest-key-bindings, execute-extended-command):
> Move from keyboard.c.
Yes, when execute-extended-command was reimplemented in Lisp, the
special code which produced "\370erase-buffer^M" was lost.
Does the change below produce good results? If so, can anyone suggest
a more elegant way of squirreling M-x into this-command-keys?
diff --git a/lisp/simple.el b/lisp/simple.el
index 441713a..c0dad2d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1733,6 +1733,9 @@ 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 <cmd> RET is nothing more than a "key
diff --git a/src/keyboard.c b/src/keyboard.c
index a86e7c5..b1eeb03 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10001,6 +10001,28 @@ 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);
+
+ 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 +11233,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);
next prev parent reply other threads:[~2017-02-03 21:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 12:34 bug#25612: 26.0.50; Slightly suboptimal message for disabled commands Philipp Stephani
2017-02-03 13:19 ` Eli Zaretskii
2017-02-03 14:15 ` Philipp Stephani
2017-02-03 15:10 ` Eli Zaretskii
2017-02-03 15:54 ` Philipp Stephani
2017-02-03 21:16 ` Eli Zaretskii [this message]
2017-02-10 9:00 ` Eli Zaretskii
2017-02-12 15:12 ` Philipp Stephani
2017-02-18 10:31 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83vasrt1p0.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=25612@debbugs.gnu.org \
--cc=p.stephani2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.