From dec6f0ccf57ea590c199b6cdf39c6fe93d67d06b Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 26 Nov 2017 19:16:16 -0500 Subject: [PATCH] Improve edit-kbd-macro prompting in case of remapped keys (Bug#29399) * 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], \\[view-lossage],\ + 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) kmacro) (cond (store-hook (setq mac keys) (setq cmd nil)) - ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro - kmacro-end-or-call-macro kmacro-end-and-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)) -- 2.11.0