aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Baugh2023-11-10 11:27:10 -0500
committerEli Zaretskii2023-11-15 19:12:46 +0200
commit7cfe088bc35f14391014b4f93a784fdef412da9c (patch)
treed3d34cab3ab9601c2b9aa090385eea30ecbc5a56
parent1a1f47e4a1fb70e6810f9eabd0f1826b71a2bcb0 (diff)
downloademacs-7cfe088bc35f14391014b4f93a784fdef412da9c.tar.gz
emacs-7cfe088bc35f14391014b4f93a784fdef412da9c.zip
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)
-rw-r--r--lisp/emacs-lisp/map-ynp.el10
1 files changed, 4 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index cb1cc88e78f..fffb199e2ea 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -168,16 +168,14 @@ The function's value is the number of actions taken."
168 (key-description (vector help-char))) 168 (key-description (vector help-char)))
169 (if minibuffer-auto-raise 169 (if minibuffer-auto-raise
170 (raise-frame (window-frame (minibuffer-window)))) 170 (raise-frame (window-frame (minibuffer-window))))
171 (while (progn 171 (setq char (read-event))
172 (setq char (read-event))
173 ;; If we get -1, from end of keyboard
174 ;; macro, try again.
175 (equal char -1)))
176 ;; Show the answer to the question. 172 ;; Show the answer to the question.
177 (message "%s(y, n, !, ., q, %sor %s) %s" 173 (message "%s(y, n, !, ., q, %sor %s) %s"
178 prompt user-keys 174 prompt user-keys
179 (key-description (vector help-char)) 175 (key-description (vector help-char))
180 (single-key-description char))) 176 (if (equal char -1)
177 "[end-of-keyboard-macro]"
178 (single-key-description char))))
181 (setq def (lookup-key map (vector char)))) 179 (setq def (lookup-key map (vector char))))
182 (cond ((eq def 'exit) 180 (cond ((eq def 'exit)
183 (setq next (lambda () nil))) 181 (setq next (lambda () nil)))