Commit 9c51a9d0 authored by Juri Linkov's avatar Juri Linkov

* 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
parent 14d29587
Pipeline #10155 passed with stages
in 11 minutes and 11 seconds
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment