[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt

From: Noam Postavsky
Subject: bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
Date: Sun, 26 Nov 2017 19:55:11 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

tags 29399 + patch

Drew Adams <address@hidden> writes:

> UNLESS the user (or `smex-mode' or whatever) actually
> substitutes `smex' for `execute-extended-command' keys,
> using remapping or using `substitute-key-definition'.

Ah, I didn't realize before, but if you do

    (define-key global [remape execute-extended-command] 'smex)

then substitute-command-keys still shows M-x for
\\[execute-extended-command].  The following patch updates the prompt,
and also the checks non-remapped key bindings for the key sequence

>From dec6f0ccf57ea590c199b6cdf39c6fe93d67d06b Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Sun, 26 Nov 2017 19:16:16 -0500
Subject: [PATCH] Improve edit-kbd-macro prompting in case of remapped keys

* lisp/edmacro.el (edit-kbd-macro): Use substitute-command-keys to
present the current bindings in the prompt.  Check the the
non-remapped binding of the entered key sequence as well.
 lisp/edmacro.el | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index b050f4d64c..dc840ef1f1 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -88,20 +88,26 @@ edmacro-original-buffer
 (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook)
   "Edit a keyboard macro.
 At the prompt, type any key sequence which is bound to a keyboard macro.
-Or, type `C-x e' or RET to edit the last keyboard macro, `C-h l' to edit
-the last 300 keystrokes as a keyboard macro, or `\\[execute-extended-command]' 
to edit a macro by
-its command name.
+Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last
+keyboard macro, `\\[view-lossage]' to edit the last 300
+keystrokes as a keyboard macro, or `\\[execute-extended-command]'
+to edit a macro by its command name.
 With a prefix argument, format the macro in a more concise way."
-  (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
+  (interactive
+   (list (read-key-sequence (substitute-command-keys "Keyboard macro to edit \
+\(\\[kmacro-end-and-call-macro], \\[execute-extended-command], 
+ or keys): "))
+         current-prefix-arg))
   (when keys
     (let ((cmd (if (arrayp keys) (key-binding keys) keys))
+          (cmd-noremap (when (arrayp keys) (key-binding keys nil t)))
          (mac nil) (mac-counter nil) (mac-format nil)
       (cond (store-hook
             (setq mac keys)
             (setq cmd nil))
-           ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro
-                            kmacro-end-or-call-macro 
+           ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro 
kmacro-end-or-call-macro kmacro-end-and-call-macro))
+                 (memq cmd-noremap '(call-last-kbd-macro kmacro-call-macro 
kmacro-end-or-call-macro kmacro-end-and-call-macro))
                 (member keys '("\r" [return])))
             (or last-kbd-macro
                 (y-or-n-p "No keyboard macro defined.  Create one? ")
@@ -109,13 +115,14 @@ edit-kbd-macro
             (setq mac (or last-kbd-macro ""))
             (setq keys nil)
             (setq cmd 'last-kbd-macro))
-           ((eq cmd 'execute-extended-command)
+           ((memq 'execute-extended-command (list cmd cmd-noremap))
             (setq cmd (read-command "Name of keyboard macro to edit: "))
             (if (string-equal cmd "")
                 (error "No command name given"))
             (setq keys nil)
             (setq mac (symbol-function cmd)))
-           ((memq cmd '(view-lossage electric-view-lossage))
+           ((or (memq cmd '(view-lossage electric-view-lossage))
+                 (memq cmd-noremap '(view-lossage electric-view-lossage)))
             (setq mac (recent-keys))
             (setq keys nil)
             (setq cmd 'last-kbd-macro))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]