diff options
| author | Noam Postavsky | 2017-11-26 19:16:16 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2017-12-02 09:35:44 -0500 |
| commit | 98ca7d5f26f5bdde44864c7f24dafb6725fca09f (patch) | |
| tree | 0b93fba409dd1e10c251625cd93c127d65db1b68 | |
| parent | c02c1f6be7befdaf4f3987148db18121e1081dae (diff) | |
| download | emacs-98ca7d5f26f5bdde44864c7f24dafb6725fca09f.tar.gz emacs-98ca7d5f26f5bdde44864c7f24dafb6725fca09f.zip | |
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.
| -rw-r--r-- | lisp/edmacro.el | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/edmacro.el b/lisp/edmacro.el index b050f4d64c7..dc840ef1f19 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el | |||
| @@ -88,20 +88,26 @@ Default nil means to write characters above \\177 in octal notation." | |||
| 88 | (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook) | 88 | (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook) |
| 89 | "Edit a keyboard macro. | 89 | "Edit a keyboard macro. |
| 90 | At the prompt, type any key sequence which is bound to a keyboard macro. | 90 | At the prompt, type any key sequence which is bound to a keyboard macro. |
| 91 | Or, type `C-x e' or RET to edit the last keyboard macro, `C-h l' to edit | 91 | Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last |
| 92 | the last 300 keystrokes as a keyboard macro, or `\\[execute-extended-command]' to edit a macro by | 92 | keyboard macro, `\\[view-lossage]' to edit the last 300 |
| 93 | its command name. | 93 | keystrokes as a keyboard macro, or `\\[execute-extended-command]' |
| 94 | to edit a macro by its command name. | ||
| 94 | With a prefix argument, format the macro in a more concise way." | 95 | With a prefix argument, format the macro in a more concise way." |
| 95 | (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP") | 96 | (interactive |
| 97 | (list (read-key-sequence (substitute-command-keys "Keyboard macro to edit \ | ||
| 98 | \(\\[kmacro-end-and-call-macro], \\[execute-extended-command], \\[view-lossage],\ | ||
| 99 | or keys): ")) | ||
| 100 | current-prefix-arg)) | ||
| 96 | (when keys | 101 | (when keys |
| 97 | (let ((cmd (if (arrayp keys) (key-binding keys) keys)) | 102 | (let ((cmd (if (arrayp keys) (key-binding keys) keys)) |
| 103 | (cmd-noremap (when (arrayp keys) (key-binding keys nil t))) | ||
| 98 | (mac nil) (mac-counter nil) (mac-format nil) | 104 | (mac nil) (mac-counter nil) (mac-format nil) |
| 99 | kmacro) | 105 | kmacro) |
| 100 | (cond (store-hook | 106 | (cond (store-hook |
| 101 | (setq mac keys) | 107 | (setq mac keys) |
| 102 | (setq cmd nil)) | 108 | (setq cmd nil)) |
| 103 | ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro | 109 | ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro)) |
| 104 | kmacro-end-or-call-macro kmacro-end-and-call-macro)) | 110 | (memq cmd-noremap '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro)) |
| 105 | (member keys '("\r" [return]))) | 111 | (member keys '("\r" [return]))) |
| 106 | (or last-kbd-macro | 112 | (or last-kbd-macro |
| 107 | (y-or-n-p "No keyboard macro defined. Create one? ") | 113 | (y-or-n-p "No keyboard macro defined. Create one? ") |
| @@ -109,13 +115,14 @@ With a prefix argument, format the macro in a more concise way." | |||
| 109 | (setq mac (or last-kbd-macro "")) | 115 | (setq mac (or last-kbd-macro "")) |
| 110 | (setq keys nil) | 116 | (setq keys nil) |
| 111 | (setq cmd 'last-kbd-macro)) | 117 | (setq cmd 'last-kbd-macro)) |
| 112 | ((eq cmd 'execute-extended-command) | 118 | ((memq 'execute-extended-command (list cmd cmd-noremap)) |
| 113 | (setq cmd (read-command "Name of keyboard macro to edit: ")) | 119 | (setq cmd (read-command "Name of keyboard macro to edit: ")) |
| 114 | (if (string-equal cmd "") | 120 | (if (string-equal cmd "") |
| 115 | (error "No command name given")) | 121 | (error "No command name given")) |
| 116 | (setq keys nil) | 122 | (setq keys nil) |
| 117 | (setq mac (symbol-function cmd))) | 123 | (setq mac (symbol-function cmd))) |
| 118 | ((memq cmd '(view-lossage electric-view-lossage)) | 124 | ((or (memq cmd '(view-lossage electric-view-lossage)) |
| 125 | (memq cmd-noremap '(view-lossage electric-view-lossage))) | ||
| 119 | (setq mac (recent-keys)) | 126 | (setq mac (recent-keys)) |
| 120 | (setq keys nil) | 127 | (setq keys nil) |
| 121 | (setq cmd 'last-kbd-macro)) | 128 | (setq cmd 'last-kbd-macro)) |