diff options
author | Juri Linkov <juri@linkov.net> | 2021-11-15 19:39:37 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-11-15 19:39:37 +0200 |
commit | c840bfe7e13200b12e3d96eb83f3972f5d25cd0c (patch) | |
tree | 99df72b0415a4f6f93b3680072fe7537f9a71943 /lisp/repeat.el | |
parent | 5044151486cfd88edceb841d2bf8378dcc906e34 (diff) | |
download | emacs-c840bfe7e13200b12e3d96eb83f3972f5d25cd0c.tar.gz emacs-c840bfe7e13200b12e3d96eb83f3972f5d25cd0c.tar.bz2 emacs-c840bfe7e13200b12e3d96eb83f3972f5d25cd0c.zip |
* lisp/repeat.el: Detect changes in the minibuffer state (bug#47566)
(repeat--prev-mb): New internal variable.
(repeat-post-hook): Check the property 'repeat-map' on the symbol
from 'this-command' in addition to 'real-this-command'. Don't allow
repeatable maps in the activated minibuffer or in the minibuffer
from another command. Set 'repeat--prev-mb' at the end.
Diffstat (limited to 'lisp/repeat.el')
-rw-r--r-- | lisp/repeat.el | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lisp/repeat.el b/lisp/repeat.el index ac08952eaa8..4ad6019a04d 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -402,12 +402,17 @@ See `describe-repeat-maps' for a list of all repeatable commands." (length commands) (length (delete-dups keymaps)))))) +(defvar repeat--prev-mb '(0) + "Previous minibuffer state.") + (defun repeat-post-hook () "Function run after commands to set transient keymap for repeatable keys." (let ((was-in-progress repeat-in-progress)) (setq repeat-in-progress nil) (when repeat-mode (let ((rep-map (or repeat-map + (and (symbolp this-command) + (get this-command 'repeat-map)) (and (symbolp real-this-command) (get real-this-command 'repeat-map))))) (when rep-map @@ -415,11 +420,16 @@ See `describe-repeat-maps' for a list of all repeatable commands." (setq rep-map (symbol-value rep-map))) (let ((map (copy-keymap rep-map))) - ;; 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 (and (zerop (minibuffer-depth)) ; avoid remapping in prompts - (or (lookup-key map (this-command-keys-vector)) - prefix-arg)) + (when (and + ;; Detect changes in the minibuffer state to allow repetitions + ;; in the same minibuffer, but not when the minibuffer is activated + ;; in the middle of repeating sequence (bug#47566). + (or (< (minibuffer-depth) (car repeat--prev-mb)) + (eq current-minibuffer-command (cdr repeat--prev-mb))) + ;; Exit when the last char is not among repeatable keys, + ;; so e.g. `C-x u u' repeats undo, whereas `C-/ u' doesn't. + (or (lookup-key map (this-command-keys-vector)) + prefix-arg)) ;; Messaging (unless prefix-arg @@ -449,6 +459,7 @@ See `describe-repeat-maps' for a list of all repeatable commands." (funcall repeat-echo-function nil))))))))))) (setq repeat-map nil) + (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command)) (when (and was-in-progress (not repeat-in-progress)) (when repeat-exit-timer (cancel-timer repeat-exit-timer) |