* lisp/repeat.el: Use same logic for repeat-check-key and repeat-exit-timeout.

* lisp/repeat.el (repeat-check-key): Use for repeat-check-key the same logic
as is used for repeat-exit-timeout in repeat-post-hook (bug#51390).
(repeat-post-hook): Check for repeat-exit-timeout symbol property.
This commit is contained in:
Juri Linkov 2021-12-01 19:41:37 +02:00
parent 8230a47ecc
commit 334ff0232e

View file

@ -345,7 +345,9 @@ For example, you can set it to <return> like `isearch-exit'."
(defcustom repeat-exit-timeout nil (defcustom repeat-exit-timeout nil
"Break the repetition chain of keys after specified timeout. "Break the repetition chain of keys after specified timeout.
When a number, exit the transient repeating mode after idle time When a number, exit the transient repeating mode after idle time
of the specified number of seconds." of the specified number of seconds.
You can also set the property `repeat-exit-timeout' on the command symbol.
This property can override the value of this variable."
:type '(choice (const :tag "No timeout to exit repeating sequence" nil) :type '(choice (const :tag "No timeout to exit repeating sequence" nil)
(number :tag "Timeout in seconds to exit repeating")) (number :tag "Timeout in seconds to exit repeating"))
:group 'convenience :group 'convenience
@ -431,8 +433,9 @@ See `describe-repeat-maps' for a list of all repeatable commands."
(defun repeat-check-key (key map) (defun repeat-check-key (key map)
"Check if the last key is suitable to activate the repeating MAP." "Check if the last key is suitable to activate the repeating MAP."
(let ((property (repeat--command-property 'repeat-check-key))) (let* ((prop (repeat--command-property 'repeat-check-key))
(or (if repeat-check-key (eq property 'no) (not (eq property t))) (check-key (unless (eq prop 'no) (or prop repeat-check-key))))
(or (not check-key)
(lookup-key map (vector key)) (lookup-key map (vector key))
;; Try without modifiers: ;; Try without modifiers:
(lookup-key map (vector (event-basic-type key)))))) (lookup-key map (vector (event-basic-type key))))))
@ -475,14 +478,16 @@ See `describe-repeat-maps' for a list of all repeatable commands."
(cancel-timer repeat-exit-timer) (cancel-timer repeat-exit-timer)
(setq repeat-exit-timer nil)) (setq repeat-exit-timer nil))
(when repeat-exit-timeout (let* ((prop (repeat--command-property 'repeat-exit-timeout))
(setq repeat-exit-timer (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout))))
(run-with-idle-timer (when timeout
repeat-exit-timeout nil (setq repeat-exit-timer
(lambda () (run-with-idle-timer
(setq repeat-in-progress nil) timeout nil
(funcall exitfun) (lambda ()
(funcall repeat-echo-function nil))))))))))) (setq repeat-in-progress nil)
(funcall exitfun)
(funcall repeat-echo-function nil))))))))))))
(setq repeat-map nil) (setq repeat-map nil)
(setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command)) (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command))