GNU bug report logs - #67046
29.1.50; map-y-or-n-p infinite loops if it's at the end of a kmacro

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Fri, 10 Nov 2023 16:45:01 UTC

Severity: normal

Found in version 29.1.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: 67046 <at> debbugs.gnu.org
Subject: bug#67046: 29.1.50; map-y-or-n-p infinite loops if it's at the end of a kmacro
Date: Fri, 10 Nov 2023 11:47:36 -0500
[Message part 1 (text/plain, inline)]
Patch:

[0001-Don-t-infinite-loop-in-map-y-or-n-p-if-at-the-end-of.patch (text/x-patch, inline)]
From d7aa9644b308a936926b1074d0f6eac3e425b011 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Fri, 10 Nov 2023 11:27:10 -0500
Subject: [PATCH] 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)
---
 lisp/emacs-lisp/map-ynp.el | 10 ++++------
 1 file 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 @@ map-y-or-n-p
 				(key-description (vector help-char)))
 		       (if minibuffer-auto-raise
 			   (raise-frame (window-frame (minibuffer-window))))
-		       (while (progn
-				(setq char (read-event))
-				;; If we get -1, from end of keyboard
-				;; macro, try again.
-                                (equal char -1)))
+		       (setq char (read-event))
 		       ;; Show the answer to the question.
 		       (message "%s(y, n, !, ., q, %sor %s) %s"
 				prompt user-keys
 				(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))))
 		   (cond ((eq def 'exit)
 			  (setq next (lambda () nil)))
-- 
2.39.3


This bug report was last modified 1 year and 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.