From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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 Message-ID: <83lfc3rfvp.fsf@gnu.org> References: <83r1lz60so.fsf@gnu.org> <83a6sm5rlr.fsf@gnu.org> <83pn1h401u.fsf@gnu.org> <83k0rp3wew.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32398"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46243@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 04 17:15:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7hHc-0008G7-Cn for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 17:15:04 +0100 Original-Received: from localhost ([::1]:33174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hHb-0006Kt-AF for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 11:15:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7gvK-0006ze-4R for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 10:52:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7gvJ-0007rK-Re for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 10:52:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7gvJ-0005NC-Pp for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 10:52:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 15:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46243 X-GNU-PR-Package: emacs Original-Received: via spool by 46243-submit@debbugs.gnu.org id=B46243.161245386620577 (code B ref 46243); Thu, 04 Feb 2021 15:52:01 +0000 Original-Received: (at 46243) by debbugs.gnu.org; 4 Feb 2021 15:51:06 +0000 Original-Received: from localhost ([127.0.0.1]:42040 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7guQ-0005Lp-4J for submit@debbugs.gnu.org; Thu, 04 Feb 2021 10:51:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7guN-0005LI-RD for 46243@debbugs.gnu.org; Thu, 04 Feb 2021 10:51:04 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39274) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7guI-0007M4-E5; Thu, 04 Feb 2021 10:50:58 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4874 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l7gu7-0000xv-Eh; Thu, 04 Feb 2021 10:50:51 -0500 In-Reply-To: (message from Stefan Monnier on Wed, 03 Feb 2021 12:42:03 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199304 Archived-At: > From: Stefan Monnier > 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);