GNU bug report logs -
#32257
26.1; read-multiple-choice inf loops on mouse clicks
Previous Next
Reported by: Noam Postavsky <npostavs <at> gmail.com>
Date: Tue, 24 Jul 2018 12:07:01 UTC
Severity: normal
Tags: fixed, patch
Found in version 26.1
Fixed in version 26.3
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #79 received at control <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 32257 + patch
quit
Andy Moreton <andrewjmoreton <at> gmail.com> writes:
> On Wed 01 Aug 2018, Eli Zaretskii wrote:
>>>
>>> Noam's original patch may bring some possibility of new problems,
>>> but it does at least fix the original problem (on emacs-26 and
>>> master).
>>
>> Fixing a problem and introducing another doesn't sound wise to me.
>> We've been there several times during the last years, and I don't want
>> to make the same mistake again. Sorry.
>
> Perhaps reverting the patches that introduced read-multiple-choice
> is the right answer then.
How about for emacs-26, we call read-event only after receiving the
problematic error. This works around the problem, and should be safe
enough, since it only triggers when we would otherwise be ending up in
an infloop anyway.
[0001-Avoid-infloop-in-read-multiple-choice-Bug-32257.patch (text/x-diff, inline)]
From 8545e36df343cc169d7ae1ab3a43c9805cd51015 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Tue, 21 May 2019 20:33:09 -0400
Subject: [PATCH] Avoid infloop in read-multiple-choice (Bug#32257)
* lisp/emacs-lisp/rmc.el (read-multiple-choice): When `read-char'
signals an error "Non-character input-event", call `read-event' to
take the non-character event out of the queue. Don't merge to master,
we just use `read-event' directly there, rather than this solution
which relies a particular error message.
---
lisp/emacs-lisp/rmc.el | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 6d1adae974..5411f2ba77 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -116,10 +116,15 @@ read-multiple-choice
(cons (capitalize (cadr elem))
(car elem)))
choices)))
- (condition-case nil
+ (condition-case err
(let ((cursor-in-echo-area t))
(read-char))
- (error nil))))
+ (error (when (equal (cadr err) "Non-character input-event")
+ ;; Use up the non-character input-event.
+ ;; Otherwise we'll just keep reading it
+ ;; again and again (Bug#32257).
+ (read-event))
+ nil))))
(setq answer (lookup-key query-replace-map (vector tchar) t))
(setq tchar
(cond
--
2.11.0
[Message part 3 (text/plain, inline)]
And master can just use read-event.
[0001-Avoid-infloop-in-read-multiple-choice-Bug-32257.patch (text/x-diff, inline)]
From f1f32043f65dc19b6d63cf1ce52ef19b46c14e22 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Tue, 21 May 2019 20:38:00 -0400
Subject: [PATCH] Avoid infloop in read-multiple-choice (Bug#32257)
* lisp/emacs-lisp/rmc.el (read-multiple-choice): Use `read-event'
which won't get stuck (return the same event over and over again) for
non-character events, unlike `read-char'.
---
lisp/emacs-lisp/rmc.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 6d1adae974..47f3b8dc9c 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -118,7 +118,7 @@ read-multiple-choice
choices)))
(condition-case nil
(let ((cursor-in-echo-area t))
- (read-char))
+ (read-event))
(error nil))))
(setq answer (lookup-key query-replace-map (vector tchar) t))
(setq tchar
--
2.11.0
This bug report was last modified 5 years and 361 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.