bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46243: [External] : Re: bug#46243: 26.3; If invoke menu item that re


From: Eli Zaretskii
Subject: bug#46243: [External] : Re: bug#46243: 26.3; If invoke menu item that reads a char, get keystrokes echo
Date: Thu, 04 Feb 2021 17:50:50 +0200

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: drew.adams@oracle.com,  46243@debbugs.gnu.org
> Date: Wed, 03 Feb 2021 12:42:03 -0500
> 
> > Do you happen to remember how you came to think that
> > echo_message_buffer was involved in that old bug report's scenario?
> 
> Sadly, no.

I feared you'd say that.

I took a look at the related code, including the changes in Emacs 23
that caused bug#15332, but didn't see any clear suspects.  Which may
not be surprising, as the complex system of variables and flags we use
in keyboard.c to DTRT with this stuff is above my pay grade.

So I propose the much simpler patch below.  It may look like a kludgey
band-aid at first sight, but OTOH consider this:

  . it seems to fix the problem without re-introducing the older bug
  . it looks like TRT because we definitely don't want any echoing
    when the prompt is displayed
  . it mimics what we do when message_with_string is called with its
    last argument non-zero: in that case message3 calls cancel_echoing
    unconditionally (whereas message3_nolog does not)

(The last point caused me to consider making this change inside
message_with_string, but there's one call of that function with last
argument zero, in keyboard.c, where we restore the last echo message,
so I decided not to do that.)

WDYT?

diff --git a/src/lread.c b/src/lread.c
index b33a312..010194c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -804,7 +804,10 @@ DEFUN ("read-char", Fread_char, Sread_char, 0, 3, 0,
   barf_if_interaction_inhibited ();
 
   if (! NILP (prompt))
-    message_with_string ("%s", prompt, 0);
+    {
+      cancel_echoing ();
+      message_with_string ("%s", prompt, 0);
+    }
   val = read_filtered_event (1, 1, 1, ! NILP (inherit_input_method), seconds);
 
   return (NILP (val) ? Qnil
@@ -839,7 +842,10 @@ DEFUN ("read-event", Fread_event, Sread_event, 0, 3, 0,
   barf_if_interaction_inhibited ();
 
   if (! NILP (prompt))
-    message_with_string ("%s", prompt, 0);
+    {
+      cancel_echoing ();
+      message_with_string ("%s", prompt, 0);
+    }
   return read_filtered_event (0, 0, 0, ! NILP (inherit_input_method), seconds);
 }
 
@@ -875,7 +881,10 @@ DEFUN ("read-char-exclusive", Fread_char_exclusive, 
Sread_char_exclusive, 0, 3,
   barf_if_interaction_inhibited ();
 
   if (! NILP (prompt))
-    message_with_string ("%s", prompt, 0);
+    {
+      cancel_echoing ();
+      message_with_string ("%s", prompt, 0);
+    }
 
   val = read_filtered_event (1, 1, 0, ! NILP (inherit_input_method), seconds);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]