Don't infinite loop in map-y-or-n-p if at the end of kmacro
Previously, if map-y-or-n-p got -1 from read-event (indicating no input due to the end of a keyboard macro), it would just infinite loop. Now it behaves like other commands which use read-event/read-char/etc, and just errors when we try to look up -1 in our keymap and find nothing. Also, just for the sake of users, print a slightly prettier message when this happens. * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Don't loop if we reach the end of a keyboard macro. (Bug#67046)
This commit is contained in:
parent
1a1f47e4a1
commit
7cfe088bc3
1 changed files with 4 additions and 6 deletions
|
@ -168,16 +168,14 @@ The function's value is the number of actions taken."
|
||||||
(key-description (vector help-char)))
|
(key-description (vector help-char)))
|
||||||
(if minibuffer-auto-raise
|
(if minibuffer-auto-raise
|
||||||
(raise-frame (window-frame (minibuffer-window))))
|
(raise-frame (window-frame (minibuffer-window))))
|
||||||
(while (progn
|
(setq char (read-event))
|
||||||
(setq char (read-event))
|
|
||||||
;; If we get -1, from end of keyboard
|
|
||||||
;; macro, try again.
|
|
||||||
(equal char -1)))
|
|
||||||
;; Show the answer to the question.
|
;; Show the answer to the question.
|
||||||
(message "%s(y, n, !, ., q, %sor %s) %s"
|
(message "%s(y, n, !, ., q, %sor %s) %s"
|
||||||
prompt user-keys
|
prompt user-keys
|
||||||
(key-description (vector help-char))
|
(key-description (vector help-char))
|
||||||
(single-key-description char)))
|
(if (equal char -1)
|
||||||
|
"[end-of-keyboard-macro]"
|
||||||
|
(single-key-description char))))
|
||||||
(setq def (lookup-key map (vector char))))
|
(setq def (lookup-key map (vector char))))
|
||||||
(cond ((eq def 'exit)
|
(cond ((eq def 'exit)
|
||||||
(setq next (lambda () nil)))
|
(setq next (lambda () nil)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue