From 9c51a9d00007902232865e6e6265cdd0d7075ae8 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 5 Apr 2021 23:46:35 +0300 Subject: [PATCH] * lisp/repeat.el (repeat-post-hook): Fix key lookup. * lisp/repeat.el (repeat-post-hook): Rename let-bound repeat-map to rep-map. Define let-bound prefix-command-p. Use lookup-key with this-single-command-keys instead of last-command-event. Don't show message when typing prefix keys. https://lists.gnu.org/archive/html/emacs-devel/2021-04/msg00083.html --- lisp/repeat.el | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/lisp/repeat.el b/lisp/repeat.el index a2b04b81b03..a5ab43950c2 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -364,35 +364,39 @@ When Repeat mode is enabled, and the command symbol has the property named (defun repeat-post-hook () "Function run after commands to set transient keymap for repeatable keys." (when repeat-mode - (let ((repeat-map (and (symbolp this-command) - (get this-command 'repeat-map)))) - (when repeat-map - (when (boundp repeat-map) - (setq repeat-map (symbol-value repeat-map))) - (let ((map (copy-keymap repeat-map)) - keys mess) - (map-keymap (lambda (key _) (push key keys)) map) + (let ((rep-map (and (symbolp this-command) + (get this-command 'repeat-map)))) + (when rep-map + (when (boundp rep-map) + (setq rep-map (symbol-value rep-map))) + (let ((prefix-command-p (memq this-original-command + '(universal-argument + universal-argument-more + digit-argument + negative-argument))) + (map (copy-keymap rep-map)) + keys) ;; Exit when the last char is not among repeatable keys, ;; so e.g. `C-x u u' repeats undo, whereas `C-/ u' doesn't. - (when (or (memq last-command-event keys) - (memq this-original-command '(universal-argument - universal-argument-more - digit-argument - negative-argument))) + (when (or (lookup-key map (this-single-command-keys) nil) + prefix-command-p) + ;; Messaging - (setq mess (format-message - "Repeat with %s%s" - (mapconcat (lambda (key) - (key-description (vector key))) - keys ", ") - (if repeat-exit-key - (format ", or exit with %s" - (key-description repeat-exit-key)) - ""))) - (if (current-message) - (message "%s [%s]" (current-message) mess) - (message mess)) + (unless prefix-command-p + (map-keymap (lambda (key _) (push key keys)) map) + (let ((mess (format-message + "Repeat with %s%s" + (mapconcat (lambda (key) + (key-description (vector key))) + keys ", ") + (if repeat-exit-key + (format ", or exit with %s" + (key-description repeat-exit-key)) + "")))) + (if (current-message) + (message "%s [%s]" (current-message) mess) + (message mess)))) ;; Adding an exit key (when repeat-exit-key -- 2.39.5