]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/repeat.el: Detect changes in the minibuffer state (bug#47566)
authorJuri Linkov <juri@linkov.net>
Mon, 15 Nov 2021 17:39:37 +0000 (19:39 +0200)
committerJuri Linkov <juri@linkov.net>
Mon, 15 Nov 2021 17:39:37 +0000 (19:39 +0200)
(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.

lisp/repeat.el

index ac08952eaa82f1b7f80840554007c5096df5bc3a..4ad6019a04d97755637c1a641d990edd85a5a779 100644 (file)
@@ -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)