unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 46243@debbugs.gnu.org
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	[thread overview]
Message-ID: <83lfc3rfvp.fsf@gnu.org> (raw)
In-Reply-To: <jwv1rdxgibu.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 03 Feb 2021 12:42:03 -0500)

> 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);
 





  parent reply	other threads:[~2021-02-04 15:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 18:50 bug#46243: 26.3; If invoke menu item that reads a char, get keystrokes echo Drew Adams
2021-02-01 19:06 ` Drew Adams
2021-02-01 19:33 ` Eli Zaretskii
2021-02-01 22:30   ` bug#46243: [External] : " Drew Adams
2021-02-02 17:04     ` Eli Zaretskii
2021-02-03 15:56       ` Eli Zaretskii
2021-02-03 16:16         ` Stefan Monnier
2021-02-03 17:15           ` Eli Zaretskii
2021-02-03 17:42             ` Stefan Monnier
2021-02-03 19:56               ` Stefan Monnier
2021-02-04 15:50               ` Eli Zaretskii [this message]
2021-02-04 16:50                 ` Stefan Monnier
2021-02-04 17:37                   ` Eli Zaretskii
2021-02-04 19:23                     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83lfc3rfvp.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=46243@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).