GNU bug report logs - #33749
26.1; input-decode-map to empty vector should preserve echo area

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Yuri Khan <yurivkhan@HIDDEN>; dated Fri, 14 Dec 2018 22:26:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 1 Jan 2019 16:09:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 01 11:09:43 2019
Received: from localhost ([127.0.0.1]:44098 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1geMbu-00070U-VJ
	for submit <at> debbugs.gnu.org; Tue, 01 Jan 2019 11:09:43 -0500
Received: from mail-oi1-f175.google.com ([209.85.167.175]:39180)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1geMbt-00070G-Ew
 for 33749 <at> debbugs.gnu.org; Tue, 01 Jan 2019 11:09:42 -0500
Received: by mail-oi1-f175.google.com with SMTP id i6so23506199oia.6
 for <33749 <at> debbugs.gnu.org>; Tue, 01 Jan 2019 08:09:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc:content-transfer-encoding;
 bh=hJIOiur314DT+obuYlzZGa8R0mLX6eYDonx/4fqkdhM=;
 b=eTxDFk2MoMMIBM74peTAe9n9dzJcX+mthqzcHTUYTzeHIJmk5eBoPFeBpF0iL4q927
 bLpzrOoDUPSGKJcaS095DFx6N/JhXsTkSl7vDalG36C78TZ3Rm7uyBRzhakazxnZ0N/6
 uNFQzDHKOCIL8hqhiXRZunyXaS0eYzUw2tX27+q0Wqn3fmuG2NFB3zpRZf4gclqZkt1p
 O6VWoyaMsQnKdsnGXKUyNioQunBL9+ZAnrxSwYJJgFu8YcARg/SZowH6O5aiDwXxRS5V
 Ih+Ce7XEUmF5HGTZRRKn9m4u/SzqEoYiWGpJNU2eDfJL91r/u5ro2+DS1/JKwFGKU6RL
 TDrw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc:content-transfer-encoding;
 bh=hJIOiur314DT+obuYlzZGa8R0mLX6eYDonx/4fqkdhM=;
 b=U/5cfGSmoBuvicwdMWXjJFrDzQLE+C6kDdFRSuEFk8fUxbqV9nggW2pl3mdoRNqK6L
 vURWrkd6/wD2Thb428NpCHBKzaynKoumRZT72N4w/lWZtCSflPJjkU04J/pF9YIZ6kX5
 geQjCO4vYGHmEJNP9XXiIlHxGmiMNuYEOUDuurJByVSB1WMQqnUkW3ID9ohgnuyHaOiW
 pYsY4tWZdNwQk0U7Fbensr/YwvKybtV+sABHyPQbQ2NS904h6Lb8d+mkMj7L9Cgnwizu
 QfuHXBz++0gX3UDMgjmqvLB3NzKFCRrhsRDnc9hUECQajTkEbWGYf2DPvBufX0IS6kld
 7tTw==
X-Gm-Message-State: AJcUukfR159inB4rzFnW4squW7xpCS9kxmNd1DlkxDV1V9QXUts6s45u
 XkDgQlCsyFe53fBeUz4lFYBrSKhfhszjiR5j6PU=
X-Google-Smtp-Source: ALg8bN4lRa1pFi/8l6TIAEwavrjRgxX49WXPecxTO1NqsuRLO5356bLcSJ/ND5gnXfP44zNljpOkwM+db7bA5pCNdg4=
X-Received: by 2002:a54:4f8f:: with SMTP id g15mr8568588oiy.166.1546358975833; 
 Tue, 01 Jan 2019 08:09:35 -0800 (PST)
MIME-Version: 1.0
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
 <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
 <jwvbm59za4j.fsf-monnier+emacs@HIDDEN> <835zvh8k7x.fsf@HIDDEN>
 <jwv5zvhz8cy.fsf-monnier+emacs@HIDDEN>
In-Reply-To: <jwv5zvhz8cy.fsf-monnier+emacs@HIDDEN>
From: Yuri Khan <yurivkhan@HIDDEN>
Date: Tue, 1 Jan 2019 23:09:23 +0700
Message-ID: <CAP_d_8VNUmeDp2spnH9iF2Ps_JRFnHckQxeKd=Nd2=woFV+LRg@HIDDEN>
Subject: Re: bug#33749: 26.1; input-decode-map to empty vector should preserve
 echo area
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33749
Cc: Eli Zaretskii <eliz@HIDDEN>, 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Wed, Dec 26, 2018 at 3:07 AM Stefan Monnier <monnier@HIDDEN> w=
rote:

> Note also that the current patch is likely not quite right yet anyway:
> I mostly posted it for discussion.  E.g. I think where I put it
> currently, it fails to be run for single-key commands.

Alas, it fails in more than that one way.

    (define-key input-decode-map (kbd "<f5> <f5>") [])

    <f5> (wait 1s)
    =E2=86=92 f5-

    <f5> (again)
    =E2=86=92 f5 f5-

i.e., although we are in the start state, the echo area contains the
last path that led to it;

    <f5> (third time)
    =E2=86=92 f5-

    C-g
    =E2=86=92 <f5> C-g is undefined

After that it breaks:

    <f5> (and wait 1s again)
    =E2=86=92 (nothing happens) <f5> C-g is undefined

    x
    =E2=86=92 <f5> x is undefined

i.e. it =E2=80=9Cheard=E2=80=9D the <f5> but did not echo it.

Also:

    ESC (and wait 1s)
    =E2=86=92 ESC-

    <f5>
    =E2=86=92 ESC f5-

    <f5>
    =E2=86=92

The echo area clears but the current prefix is ESC:

    C-g
    =E2=86=92 C-M-g is undefined


Do we have anything resembling a feature specification for echoing?
Automated tests? Even just a mechanism for testing key sequence
reading and echoing?

I see a file, test/src/keyboard-tests.el. I see there is a mechanism
to feed keystrokes, either immediately or on a timer. I will look if
these can be used to exercise the echoing code path.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 26 Dec 2018 03:33:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 25 22:33:12 2018
Received: from localhost ([127.0.0.1]:36548 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gbzwR-0004lf-T8
	for submit <at> debbugs.gnu.org; Tue, 25 Dec 2018 22:33:12 -0500
Received: from eggs.gnu.org ([208.118.235.92]:41236)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1gbzwL-0004l3-Vq
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 22:33:06 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1gbzwB-0007sv-UV
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 22:32:56 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60377)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1gbzwB-0007sp-Rc; Tue, 25 Dec 2018 22:32:51 -0500
Received: from [176.228.60.248] (port=4050 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1gbzwB-0003sn-GE; Tue, 25 Dec 2018 22:32:51 -0500
Date: Wed, 26 Dec 2018 05:32:47 +0200
Message-Id: <834lb17yjk.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-reply-to: <jwv5zvhz8cy.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Tue, 25 Dec 2018 15:07:50 -0500)
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
 <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
 <jwvbm59za4j.fsf-monnier+emacs@HIDDEN> <835zvh8k7x.fsf@HIDDEN>
 <jwv5zvhz8cy.fsf-monnier+emacs@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33749
Cc: yurivkhan@HIDDEN, 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: yurivkhan@HIDDEN, 33749 <at> debbugs.gnu.org
> Date: Tue, 25 Dec 2018 15:07:50 -0500
> 
> >> I think The Right Thing to do is likely to move this code to
> >> read_key_sequence, more specifically, move it to the point where we
> >> *know* we really do have an event.
> >> IOW, I think the patch below might be a better option (where we test
> >> `indec.start > 0` to make sure some *decoded* event was read).
> > Where in that patch is the variable that I asked for, which would
> > trigger this special behavior?
> 
> Nowhere ;-)
> 
> Mostly because I don't know where we could set this variable (other
> than globally).
> 
> If you want me to add a global var to control whether we use the old or
> the new behavior, I'm fine with that.

Yes, please.

> Note also that the current patch is likely not quite right yet anyway:
> I mostly posted it for discussion.  E.g. I think where I put it
> currently, it fails to be run for single-key commands.

Yes, I understand.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 25 Dec 2018 20:07:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 25 15:07:56 2018
Received: from localhost ([127.0.0.1]:36449 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gbszc-0001Sj-34
	for submit <at> debbugs.gnu.org; Tue, 25 Dec 2018 15:07:56 -0500
Received: from chene.dit.umontreal.ca ([132.204.246.20]:45812)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1gbsza-0001SZ-0s
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 15:07:54 -0500
Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca
 [132.204.27.242])
 by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id wBPK7phS008188;
 Tue, 25 Dec 2018 15:07:51 -0500
Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848)
 id CCDD8AE1EF; Tue, 25 Dec 2018 15:07:50 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
Message-ID: <jwv5zvhz8cy.fsf-monnier+emacs@HIDDEN>
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
 <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
 <jwvbm59za4j.fsf-monnier+emacs@HIDDEN> <835zvh8k7x.fsf@HIDDEN>
Date: Tue, 25 Dec 2018 15:07:50 -0500
In-Reply-To: <835zvh8k7x.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 25 Dec
 2018 21:44:34 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-NAI-Spam-Flag: NO
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0
X-NAI-Spam-Rules: 2 Rules triggered
	EDT_SA_DN_PASS=0, RV6446=0
X-NAI-Spam-Version: 2.3.0.9418 : core <6446> : inlines <6990> : streams
 <1808180> : uri <2769936>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 33749
Cc: yurivkhan@HIDDEN, 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> I think The Right Thing to do is likely to move this code to
>> read_key_sequence, more specifically, move it to the point where we
>> *know* we really do have an event.
>> IOW, I think the patch below might be a better option (where we test
>> `indec.start > 0` to make sure some *decoded* event was read).
> Where in that patch is the variable that I asked for, which would
> trigger this special behavior?

Nowhere ;-)

Mostly because I don't know where we could set this variable (other
than globally).

If you want me to add a global var to control whether we use the old or
the new behavior, I'm fine with that.

Note also that the current patch is likely not quite right yet anyway:
I mostly posted it for discussion.  E.g. I think where I put it
currently, it fails to be run for single-key commands.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 25 Dec 2018 19:44:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 25 14:44:52 2018
Received: from localhost ([127.0.0.1]:36446 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gbsdG-0000tR-Gq
	for submit <at> debbugs.gnu.org; Tue, 25 Dec 2018 14:44:50 -0500
Received: from eggs.gnu.org ([208.118.235.92]:48037)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1gbsdE-0000tB-UI
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 14:44:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1gbsd6-000877-Ku
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 14:44:43 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54058)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1gbsd6-000871-Hd; Tue, 25 Dec 2018 14:44:40 -0500
Received: from [176.228.60.248] (port=3171 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1gbsd6-0006os-5R; Tue, 25 Dec 2018 14:44:40 -0500
Date: Tue, 25 Dec 2018 21:44:34 +0200
Message-Id: <835zvh8k7x.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-reply-to: <jwvbm59za4j.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Tue, 25 Dec 2018 14:35:13 -0500)
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
 <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
 <jwvbm59za4j.fsf-monnier+emacs@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33749
Cc: yurivkhan@HIDDEN, 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

> From: Stefan Monnier <monnier@HIDDEN>
> Date: Tue, 25 Dec 2018 14:35:13 -0500
> Cc: 33749 <at> debbugs.gnu.org
> 
> I think The Right Thing to do is likely to move this code to
> read_key_sequence, more specifically, move it to the point where we
> *know* we really do have an event.
> 
> IOW, I think the patch below might be a better option (where we test
> `indec.start > 0` to make sure some *decoded* event was read).

Where in that patch is the variable that I asked for, which would
trigger this special behavior?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 25 Dec 2018 19:35:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 25 14:35:18 2018
Received: from localhost ([127.0.0.1]:36443 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gbsU2-0000f7-E6
	for submit <at> debbugs.gnu.org; Tue, 25 Dec 2018 14:35:18 -0500
Received: from chene.dit.umontreal.ca ([132.204.246.20]:45410)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1gbsTz-0000ey-Li
 for 33749 <at> debbugs.gnu.org; Tue, 25 Dec 2018 14:35:16 -0500
Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca
 [132.204.27.242])
 by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id wBPJZD5W005385;
 Tue, 25 Dec 2018 14:35:14 -0500
Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848)
 id B5FD9AE1EF; Tue, 25 Dec 2018 14:35:13 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Yuri Khan <yurivkhan@HIDDEN>
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
Message-ID: <jwvbm59za4j.fsf-monnier+emacs@HIDDEN>
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
 <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
Date: Tue, 25 Dec 2018 14:35:13 -0500
In-Reply-To: <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
 (Yuri Khan's message of "Sat, 22 Dec 2018 01:36:55 +0700")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-NAI-Spam-Flag: NO
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0
X-NAI-Spam-Rules: 2 Rules triggered
	EDT_SA_DN_PASS=0, RV6446=0
X-NAI-Spam-Version: 2.3.0.9418 : core <6446> : inlines <6990> : streams
 <1808178> : uri <2769924>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Also, I cannot easily add a new condition at this particular point.
> It happens when Emacs reads each character of the sequence that will
> eventually turn out to map to an empty one, but I do not know that
> will be the case until the end.

I think The Right Thing to do is likely to move this code to
read_key_sequence, more specifically, move it to the point where we
*know* we really do have an event.

IOW, I think the patch below might be a better option (where we test
`indec.start > 0` to make sure some *decoded* event was read).

>> >> Also, who/where do you intend to set input-decode-preserve-echo?
>> Ah, so you're planning to set it once and for all globally?
> Terminal-locally, if it=E2=80=99s any better.

Only marginally.


        Stefan


diff --git a/src/keyboard.c b/src/keyboard.c
index baf2f51440..92ef79b09f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2928,22 +2928,6 @@ read_char (int commandflag, Lisp_Object map,
       Vinput_method_previous_message =3D previous_echo_area_message;
     }
=20
-  /* Now wipe the echo area, except for help events which do their
-     own stuff with the echo area.  */
-  if (!CONSP (c)
-      || (!(EQ (Qhelp_echo, XCAR (c)))
-	  && !(EQ (Qswitch_frame, XCAR (c)))
-	  /* Don't wipe echo area for select window events: These might
-	     get delayed via `mouse-autoselect-window' (Bug#11304).  */
-	  && !(EQ (Qselect_window, XCAR (c)))))
-    {
-      if (!NILP (echo_area_buffer[0]))
-	{
-	  safe_run_hooks (Qecho_area_clear_hook);
-	  clear_message (1, 0);
-	}
-    }
-
  reread_for_input_method:
  from_macro:
   /* Pass this to the input method, if appropriate.  */
@@ -9070,6 +9054,23 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object =
prompt,
       /* If not, we should actually read a character.  */
       else
 	{
+          /* Now wipe the echo area, except for help events which do their
+             own stuff with the echo area.  */
+          /* FIXME: This used to happen at the end of read_char (i.e. after
+             we read the first event of a key sequence), but we now do it =
just
+             before reading the second event, and only when we know that t=
he
+             first event is a "real" one, rather than some internal event =
that
+             might be dropped altogether (e.g. help-event, switch-frame, or
+             some key that we remap to the empty sequence (bug#33749)).
+             Maybe we should even make sure that `fkey.star > 0` or maybe
+             even `keytran.start > 0`!?  */
+          if (indec.start > 0
+              && !NILP (echo_area_buffer[0]))
+	    {
+	      safe_run_hooks (Qecho_area_clear_hook);
+	      clear_message (1, 0);
+	    }
+
 	  {
 	    KBOARD *interrupted_kboard =3D current_kboard;
 	    struct frame *interrupted_frame =3D SELECTED_FRAME ();




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 21 Dec 2018 18:37:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 21 13:37:15 2018
Received: from localhost ([127.0.0.1]:58782 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gaPff-0004xB-7B
	for submit <at> debbugs.gnu.org; Fri, 21 Dec 2018 13:37:15 -0500
Received: from mail-oi1-f174.google.com ([209.85.167.174]:43684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1gaPfd-0004wz-16
 for 33749 <at> debbugs.gnu.org; Fri, 21 Dec 2018 13:37:13 -0500
Received: by mail-oi1-f174.google.com with SMTP id u18so5528211oie.10
 for <33749 <at> debbugs.gnu.org>; Fri, 21 Dec 2018 10:37:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc:content-transfer-encoding;
 bh=CWAYqIqMQfJpwuMtmYHTO3+R8OiHNc2N4Uf7Vn2r9/0=;
 b=Xcl21ifE/K1Zja4wJ5DO7ID183bJZuI/wE5OU6fgivhPAqQ2oH3qhMLp+DbYjw+aSV
 gvPV5bfh3jBanAnSFZ9u17CEEMVVItiW6cl8AR6jpZC+oGXboylIAfdjB9qhVAAPGshj
 gGsRmB12MmDm9yNohls/Qktu8wd6AoyqDNpN6pk2K9jxfXa9HbSFRVqkTE4XmEVN0shB
 EcrFQ07IYW+57n1hwWiT7sU1vpZK3rPKIlLEHchwi0SOudy+cHNb5thrYKt00wOMtqFI
 MuvVrt54kUxU3dThNoY4HJT73Usi1wMTUsrxqYrJuHNVEaR0DDp7SYqoukSbt4SHZ3Ty
 wnJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc:content-transfer-encoding;
 bh=CWAYqIqMQfJpwuMtmYHTO3+R8OiHNc2N4Uf7Vn2r9/0=;
 b=trh6h7KKP244P7m/VScRvr/5n6zxerBdX6bTEaYQEVqiopJeDhY5SB/urp7VFOBD4Y
 xuVpEaXN2PeZlLcLc2j4sKlLhsp4F/ESf9f97/K46b/EpaMF15OVAkxD3Dykq51OrVpi
 d9MJc6oI8DYhK3Wxwp2ggp3mWuEiqXk4Bi8dFqMnts2v+9R8NvtvcvUy5mEl0yCQHtqF
 8NWMs+Lrea1Wy42eURR/4yWfcb/H8k6Ny36BQAAKAJVsLdW9BVzye1gka6GAYH2a22LM
 aKVoKs8CrvJZdG4yrZpnvV7/jBYhFuNY3fLYbyg23GlTs9dUEVzbrnHhnS6N/2hWX+T/
 eP2g==
X-Gm-Message-State: AA+aEWbZ/pXwSaGFvdFR3JU1pkKUjBEPt6sTyRn2g7UoeIfqorDjQv0x
 GFTqRWG3UMuKo7E4htCa467RRq6rmPjtTbNo7uk=
X-Google-Smtp-Source: AFSGD/UBY+oM2X/1XB7oaJPYpETcVgstvLTiHRqvLra9tzZ15He/g3DNmIv8di48D3CB66JbtRRWD4JwDTgmBJfs/BQ=
X-Received: by 2002:aca:af53:: with SMTP id y80mr2178772oie.170.1545417427226; 
 Fri, 21 Dec 2018 10:37:07 -0800 (PST)
MIME-Version: 1.0
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
In-Reply-To: <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
From: Yuri Khan <yurivkhan@HIDDEN>
Date: Sat, 22 Dec 2018 01:36:55 +0700
Message-ID: <CAP_d_8X7RipC2L7d-fS=4OFLVorYxvYWZxQ6wqO2-9QvFz9Tqw@HIDDEN>
Subject: Re: bug#33749: 26.1; input-decode-map to empty vector should preserve
 echo area
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Fri, Dec 21, 2018 at 3:41 AM Stefan Monnier <monnier@HIDDEN> w=
rote:
>
> > There are many of these, that I considered it impractical to attempt
> > to prevent them all from happening.
>
> They're probably not all guilty.  That's why I'm asking if you've been
> able to find which one is the culprit.
>
> >           safe_run_hooks (Qecho_area_clear_hook);
> > =E2=86=92         clear_message (1, 0);
> >         }

> Are you saying that if you neuter all three of those, the problem
> disappears?
> If you keep any one of those is the problem still present?

The problem disappears if I comment out this one =E2=80=98clear_message=E2=
=80=99.

I looked for its history.

* In the beginning (1992-01-29 by Jim Blandy), it was unconditional.
* 1994-05-11 Karl Heuer: =E2=80=9CPreserve echo area on async buffer switch=
.=E2=80=9D
* 1994-08-19 Richard M. Stallman: =E2=80=9CDon=E2=80=99t show buffer-events=
 to the user.=E2=80=9D
* 1998-08-08 Richard M. Stallman: =E2=80=9CWhen input method returns no cha=
rs,
call cancel_echoing. Restore the previous echo area message and
this_command_keys, too.=E2=80=9D
* 1999-07-22 Gerd Moellmann: (slight refactoring)
* 1999-08-22 Gerd Moellmann: (more refactoring)
* 2005-05-11 Gerd Moellmann: =E2=80=9CDon't clear current message for help =
events; =E2=80=A6=E2=80=9D
* 2012-05-07 J=C3=A9r=C3=A9my Compostella: =E2=80=9CDon't clear the echo ar=
ea if there's
no message to clear.=E2=80=9D

That is, over time, various conditions were added around this clear,
for various reasons. The patch about input method returning no
characters uses the same kind of workaround, which is where I got this
idea.

Thing is, I do not understand what the original purpose was. It only
matters during the short interval after the initial character of the
key sequence is read, and until either the sequence is finished or
=E2=80=98echo-keystrokes=E2=80=99 seconds elapse, and it seems to only prov=
ide
immediate visual feedback for pressing a prefix key. (What am I
overlooking?)

Also, I cannot easily add a new condition at this particular point. It
happens when Emacs reads each character of the sequence that will
eventually turn out to map to an empty one, but I do not know that
will be the case until the end.

Or do I?

In the specific use case of Kitty=E2=80=99s full keyboard mode, the conditi=
on
that I=E2=80=99m looking for is =E2=80=9CThe first character of the sequenc=
e currently
being read is ESC=E2=80=9D. This is because in this mode the <escape> key
sends not just an ESC character but a whole ESC _ K p A y ESC \
sequence. That is, visual feedback is not necessary for a sole ESC
character and any sequence starting with ESC.

That condition is detectable in read_key_sequence and would need to be
passed into read_char. I could probably add a new argument to
read_char, or invent more values for its COMMANDFLAG argument. The new
logic would be governed by a terminal-local flag that essentially
means =E2=80=9Con this terminal, the ESC character always means a special k=
ey
and never the key <escape>=E2=80=9D, or a terminal-local set of characters
that always start special keys.

Do you think this is a better course of action?

> >> Also, who/where do you intend to set input-decode-preserve-echo?
> Ah, so you're planning to set it once and for all globally?

Terminal-locally, if it=E2=80=99s any better.

> That would really make it a workaround more than a fix, I think.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 20 Dec 2018 18:56:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 20 13:56:48 2018
Received: from localhost ([127.0.0.1]:56733 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ga3V1-0003kV-Ql
	for submit <at> debbugs.gnu.org; Thu, 20 Dec 2018 13:56:47 -0500
Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]:60318)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1ga3V0-0003kB-4r
 for 33749 <at> debbugs.gnu.org; Thu, 20 Dec 2018 13:56:46 -0500
Received: from fmsmemgm.homelinux.net ([23.233.195.134]) by Videotron with SMTP
 id a3UtgxsclFsgZa3Uugrzj8; Thu, 20 Dec 2018 13:56:40 -0500
X-Authority-Analysis: v=2.3 cv=Y7LWTCWN c=1 sm=1 tr=0
 a=xXJ578j8WyTliCxld3/pTA==:117 a=xXJ578j8WyTliCxld3/pTA==:17
 a=IkcTkHD0fZMA:10 a=2ur7OfE09M0A:10 a=YSjo-HGSELHF2Ga8TOwA:9
 a=7Zwj6sZBwVKJAoWSPKxL6X1jA+E=:19 a=QEXdDO2ut3YA:10
Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848)
 id 2112DAE59B; Thu, 20 Dec 2018 13:56:39 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Yuri Khan <yurivkhan@HIDDEN>
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
Message-ID: <jwvy38k1151.fsf-monnier+emacs@HIDDEN>
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
 <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
Date: Thu, 20 Dec 2018 13:56:39 -0500
In-Reply-To: <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
 (Yuri Khan's message of "Fri, 21 Dec 2018 00:33:28 +0700")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-CMAE-Envelope: MS4wfDTwr6sZ4yUqOzlRG6nlZuaX9I+ppgWU8/POztNPnAhZL0DeE15HuQyyvb3v9o7rM5HwUicZHVTz2gJ7guOqYVX3cWU1A1P+CdU14JXwYSpZiYUGjN+5
 ofNdAltWzrbfYgiWDG4j3+xsRWOaBXH7PKoP170NZW9o+oav1DBQGg1B8xyMOhbEUhz4D7+YQbltqsZ2i31fI7YYf1SFmO6VB7xCmwCn+kPYYLtqYByAhh+0
 vFlqq3VqhzxSVunzuxeVvKhmzFhucN8DCU5h4VlV1sc=
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

> There are many of these, that I considered it impractical to attempt
> to prevent them all from happening.

They're probably not all guilty.  That's why I'm asking if you've been
able to find which one is the culprit.

>           safe_run_hooks (Qecho_area_clear_hook);
> =E2=86=92         clear_message (1, 0);
>         }
[...]
>   if (INTERACTIVE && t < mock_input)
> =E2=86=92   echo_truncate (echo_start);
>
[...]
>       if (INTERACTIVE && t < mock_input)
> =E2=86=92       echo_truncate (echo_local_start);
>       this_command_key_count =3D keys_local_start;

Are you saying that if you neuter all three of those, the problem
disappears?
If you keep any one of those is the problem still present?

>> Also, who/where do you intend to set input-decode-preserve-echo?
>
> My current plan is:
>
> * term/xterm-kitty.el will define a (customizable?) user variable
> kitty-use-full-keyboard, boolean, default nil.
> * If it is nil, =E2=80=98terminal-init-xterm-kitty=E2=80=99 will call
> (terminal-init-xterm) and call it a day.
> * If =E2=80=98kitty-use-full-keyboard=E2=80=99 has been set to non-nil,
> =E2=80=98terminal-init-xterm-kitty=E2=80=99 will send to the terminal the=
 escape
> sequence enabling full keyboard mode (CSI ? 2 0 1 7 h), set up
> =E2=80=98input-decode-map=E2=80=99 and =E2=80=98local-function-key-map=E2=
=80=99 as appropriate for
> that mode, set =E2=80=98input-decode-preserve-echo=E2=80=99 to =E2=80=98t=
=E2=80=99, and perform other
> xterm-like initialization such as bracketed paste, clipboard/selection
> control, mouse, etc.

Ah, so you're planning to set it once and for all globally?
That would really make it a workaround more than a fix, I think.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 20 Dec 2018 17:33:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 20 12:33:48 2018
Received: from localhost ([127.0.0.1]:56698 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ga2Ch-0008Bx-RS
	for submit <at> debbugs.gnu.org; Thu, 20 Dec 2018 12:33:48 -0500
Received: from mail-oi1-f182.google.com ([209.85.167.182]:32958)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1ga2Cf-0008Bk-Ty
 for 33749 <at> debbugs.gnu.org; Thu, 20 Dec 2018 12:33:46 -0500
Received: by mail-oi1-f182.google.com with SMTP id c206so2556233oib.0
 for <33749 <at> debbugs.gnu.org>; Thu, 20 Dec 2018 09:33:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc:content-transfer-encoding;
 bh=gzpjA9STadVrC78uDDq+RCLj5s9tSa8t/Pz0MyA+es4=;
 b=mMIpfKa2qEL3aQIxAd/vZJIBcLxZW7PhRKjz/EkZyWzGPoVHJ+5PJqcXKa8Nwa9vhk
 uAJfq5Sf9aS/7u6QPG0dOlHnEpItRGd3CG6avg6Pb97U+o7dO7TTcvm5koZyATkH1E4r
 0kDMHUg+pG7SDmrznYPBdh7CA6edfeYDqdQUkFYCGnGKE8xYN0bCytqta5rKbzKkr00y
 iH7lGtz5KMCTWFsZ2ZCILhWicwNaX1JqNVnBbSYgTiYl/KnOgTIx6ReLFaaol00O+cSJ
 rqhJbn4BC7u+O8VeTbvsLs4B8EvkghB6Z6wNdkfBeuyEY1HrD+54yoBU2d+JieO/HYTk
 9YpA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc:content-transfer-encoding;
 bh=gzpjA9STadVrC78uDDq+RCLj5s9tSa8t/Pz0MyA+es4=;
 b=mc72VRa3v0c9UNbL32Q/nVymdyng9G+pD2hkHx94Wu/WAMvJy0uIsHqn6r0ns+lFks
 th+u2wcF68+Or4BTV6lJwXyThPF8hbAAvlc4LQbP1DYHaW/hD/1vuFtgKSxa5MyD1FNd
 5OM52zTWXzIvMGJWlxp8yVNr6PJbjC7YD+XhuHVak1IYr0b+tRpCHj996qeddGW2dOpO
 UQnGpClVwk2o4ShI9EOinwHOI6SR8SV2PLzNoy5IHscZMefQz2xC2hfl9kWKFPvmmwhS
 JWAlJyyO2ARckDrrdQhFX8erUmM6CzQBfqG6CvIV2HUaUZwoF5cba6FvX/4oR2bi0MbH
 2VWA==
X-Gm-Message-State: AA+aEWZ6DQShEdfX0KDUkoJdz5bu1k5oKUi0iZ0H5GR4BH56hPMuX6Og
 UGymcZaYuCez//rdJFCuJ9UIiyx6A6LkuTmStq0=
X-Google-Smtp-Source: AFSGD/UglzAsWyaxWaidEWXneYi2y5EvzSEQ3mso9zGek+7Jm6ZSm6F1YG0U0/vEhT8fKebOMqi2MLiwJr8bk2oiRws=
X-Received: by 2002:a54:4e1b:: with SMTP id a27mr3092943oiy.143.1545327220147; 
 Thu, 20 Dec 2018 09:33:40 -0800 (PST)
MIME-Version: 1.0
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
In-Reply-To: <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
From: Yuri Khan <yurivkhan@HIDDEN>
Date: Fri, 21 Dec 2018 00:33:28 +0700
Message-ID: <CAP_d_8V_hXUSfi3i=2ovXgUdpYXTnKyU-QbHJ5mS93B-OD+Ohw@HIDDEN>
Subject: Re: bug#33749: 26.1; input-decode-map to empty vector should preserve
 echo area
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Thu, Dec 20, 2018 at 1:05 AM Stefan Monnier <monnier@HIDDEN> w=
rote:
>
> > The call sequence that causes the echo to be cleared looks like this:
> >
> > command_loop_1 (in keyboard.c)
> >   read_key_sequence
> >     read_char
> >       redisplay
> >
> > and much of the read_char and read_key_sequence mechanics maintain
> > echoing of the current prefix sequence.
>
> Have you been able to track down the precise call to (one of the C entry
> point of) `message` which causes the echo area to be cleared in
> your case?

Ah, of course, =E2=80=98redisplay=E2=80=99 clears the echo area visually, b=
ut it is
only enacting the state set by some previous call to =E2=80=98message=E2=80=
=99 or its
subcases.

There are many of these, that I considered it impractical to attempt
to prevent them all from happening.

* In =E2=80=98read_char=E2=80=99 around keyboard.c:2948:

  /* Now wipe the echo area, except for help events which do their
     own stuff with the echo area.  */
  if (!CONSP (c)
      || (!(EQ (Qhelp_echo, XCAR (c)))
          && !(EQ (Qswitch_frame, XCAR (c)))
          /* Don't wipe echo area for select window events: These might
             get delayed via `mouse-autoselect-window' (Bug#11304).  */
          && !(EQ (Qselect_window, XCAR (c)))))
    {
      if (!NILP (echo_area_buffer[0]))
        {
          safe_run_hooks (Qecho_area_clear_hook);
=E2=86=92         clear_message (1, 0);
        }
    }

* In =E2=80=98read_key_sequence=E2=80=99 around keyboard.c:8981:

  /* These are no-ops the first time through, but if we restart, they
     revert the echo area and this_command_keys to their original state.  *=
/
  this_command_key_count =3D keys_start;
  if (INTERACTIVE && t < mock_input)
=E2=86=92   echo_truncate (echo_start);

and keyboard.c:9056:

    replay_key:
      /* These are no-ops, unless we throw away a keystroke below and
         jumped back up to replay_key; in that case, these restore the
         variables to their original state, allowing us to replay the
         loop.  */
      if (INTERACTIVE && t < mock_input)
=E2=86=92       echo_truncate (echo_local_start);
      this_command_key_count =3D keys_local_start;


> input-decode-map doesn't only apply to the beginning of a key-sequence,
> but also in the middle (e.g. in your case, when you do `C-x h` the
> input-decode-map likely applies to the "release control modifier" event
> that occurs between `C-x` and `h`).
>
> Returning -1 after `C-x` and before we got to read `h` wouldn't
> be right.

Yes, and the patch is written to only return -1 if the whole sequence
from the very beginning (i.e. start of read-key-sequence) is zeroed
out. Otherwise, after the re-reading, there is still a current prefix
and it is echoed as usual:

    $ ./emacs -Q
    (setq input-decode-preserve-echo 1)
    =E2=86=92 1
    (define-key input-decode-map (kbd "<f5> <f5>") [])
    =E2=86=92 []

    <f5>
    =E2=86=92 f5-
    <f5>
    =E2=86=92 []

    ESC
    =E2=86=92 ESC-
    <f5>
    =E2=86=92 ESC f5-
    <f5>
    =E2=86=92 ESC-


> Also, who/where do you intend to set input-decode-preserve-echo?

My current plan is:

* term/xterm-kitty.el will define a (customizable?) user variable
kitty-use-full-keyboard, boolean, default nil.
* If it is nil, =E2=80=98terminal-init-xterm-kitty=E2=80=99 will call
(terminal-init-xterm) and call it a day.
* If =E2=80=98kitty-use-full-keyboard=E2=80=99 has been set to non-nil,
=E2=80=98terminal-init-xterm-kitty=E2=80=99 will send to the terminal the e=
scape
sequence enabling full keyboard mode (CSI ? 2 0 1 7 h), set up
=E2=80=98input-decode-map=E2=80=99 and =E2=80=98local-function-key-map=E2=
=80=99 as appropriate for
that mode, set =E2=80=98input-decode-preserve-echo=E2=80=99 to =E2=80=98t=
=E2=80=99, and perform other
xterm-like initialization such as bracketed paste, clipboard/selection
control, mouse, etc.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 19 Dec 2018 18:05:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 19 13:05:46 2018
Received: from localhost ([127.0.0.1]:55074 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gZgE6-0007Nw-4u
	for submit <at> debbugs.gnu.org; Wed, 19 Dec 2018 13:05:46 -0500
Received: from pruche.dit.umontreal.ca ([132.204.246.22]:42726)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1gZgE3-0007Nm-Tr
 for 33749 <at> debbugs.gnu.org; Wed, 19 Dec 2018 13:05:44 -0500
Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242])
 by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id wBJI5gir002422;
 Wed, 19 Dec 2018 13:05:43 -0500
Received: by pastel.home (Postfix, from userid 20848)
 id 8B5626AAC2; Wed, 19 Dec 2018 13:05:42 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Yuri Khan <yurivkhan@HIDDEN>
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
Message-ID: <jwv1s6dtn33.fsf-monnier+bug#33749@HIDDEN>
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
Date: Wed, 19 Dec 2018 13:05:42 -0500
In-Reply-To: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 (Yuri Khan's message of "Sat, 15 Dec 2018 03:48:00 +0700")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-NAI-Spam-Flag: NO
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0
X-NAI-Spam-Rules: 2 Rules triggered
	EDT_SA_DN_PASS=0, RV6442=0
X-NAI-Spam-Version: 2.3.0.9418 : core <6442> : inlines <6988> : streams
 <1807600> : uri <2767099>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> The call sequence that causes the echo to be cleared looks like this:
>
> command_loop_1 (in keyboard.c)
>   read_key_sequence
>     read_char
>       redisplay
>
> and much of the read_char and read_key_sequence mechanics maintain
> echoing of the current prefix sequence.

Have you been able to track down the precise call to (one of the C entry
point of) `message` which causes the echo area to be cleared in
your case?

> * src/keyboard.c (read_key_sequence): If the current sequence is
>   mapped via `input-decode-map' to an empty sequence and
>   `input-decode-preserve-echo' is non-nil, return -1.

input-decode-map doesn't only apply to the beginning of a key-sequence,
but also in the middle (e.g. in your case, when you do `C-x h` the
input-decode-map likely applies to the "release control modifier" event
that occurs between `C-x` and `h`).

Returning -1 after `C-x` and before we got to read `h` wouldn't
be right.

Also, who/where do you intend to set input-decode-preserve-echo?


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 16 Dec 2018 08:30:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 16 03:30:49 2018
Received: from localhost ([127.0.0.1]:49881 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gYRp2-0001hE-27
	for submit <at> debbugs.gnu.org; Sun, 16 Dec 2018 03:30:48 -0500
Received: from mail-lf1-f65.google.com ([209.85.167.65]:34789)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yuri.v.khan@HIDDEN>) id 1gYRoz-0001gw-Dd
 for 33749 <at> debbugs.gnu.org; Sun, 16 Dec 2018 03:30:45 -0500
Received: by mail-lf1-f65.google.com with SMTP id p6so7267454lfc.1
 for <33749 <at> debbugs.gnu.org>; Sun, 16 Dec 2018 00:30:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=bdTiATyvjlE7dmAO73XNl7hZAtHhiQv9F26LkSvdDhU=;
 b=i5bpNnkzd5bHcVGAVvYqoZFFhgrEE0NNAlrlUK0mM6ovcGCAMsYyaJTDn/r4czPcp9
 EGZOgA1o142tcaRLzE3ZcvXoxyQpE5LCw/zKyFdz3VCxC44baztH6WdWRBeaLqRs3ei1
 vner3kVi5O1WSowvSgvzcSrhB5bmsPu3GiPUFH5dC/6+JQsAmcW/TP2LgPyTssTxCWAB
 jYLdEQFaWBdW59EIBZEb6n7rC3L402a5vARlDgnQO/fKcEDfbtpX+NGICocRrAvEt9Yf
 yBW6CmfqKm6v6UcK9lGQapt/vuhSUuKTHJYnmFCn2nSnBpIllfQs3mlu8mq4lGmsZLQU
 w3dA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:date:message-id
 :in-reply-to:references:mime-version:content-transfer-encoding;
 bh=bdTiATyvjlE7dmAO73XNl7hZAtHhiQv9F26LkSvdDhU=;
 b=FKnDtjxtUc3lWSIQSniG9dPqTIRd0IuLtKeudE9eYbEbXBaLx9jzNYW79Poos7xE2n
 zhsWZg8el3uiFjXlhxnZ9eI6gcU2mIA0eov0ank2Fig6nF6YtDP3fjBbJtu1/1svdgSa
 WbVijyYkV+/vSgaqh6TxwvXQIGqvqvl/YzEnkOXLDHXCjYEpbVyfb8nuVWXePaQMUKrA
 NcsEsc6HGZecOH8yeZdarlEYP+73ciS8bSs/49McGq/6gL84v6xe+0bRwO2nOxXTQdSk
 uZJjkpspNkvTwINhRL8xUVRNk6LiAWXt/E4+D65fYierLcwW0dmisf38ngGt+XDd/SU0
 T6Vg==
X-Gm-Message-State: AA+aEWbV0TInDTJpznYUdQYlOlof2PHYtUmnGfyxUpC84qh4zcj2pCgO
 iSehThIaUrfsg41Wb9HHZMMziLvU
X-Google-Smtp-Source: AFSGD/XUp6kuguJe6tigOju4npXag5hQxFSc68RzlBt/E/EpMQBdvUGFzU3+M2AuTB91Lcl5nY7h3Q==
X-Received: by 2002:a19:a28e:: with SMTP id l136mr5511770lfe.87.1544949038898; 
 Sun, 16 Dec 2018 00:30:38 -0800 (PST)
Received: from centaur-pc.khan.test (static.90.189.159.140.sinor.ru.
 [90.189.159.140])
 by smtp.gmail.com with ESMTPSA id z9sm1877870lfj.79.2018.12.16.00.30.36
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 16 Dec 2018 00:30:37 -0800 (PST)
From: Yuri Khan <yuri.v.khan@HIDDEN>
To: 33749 <at> debbugs.gnu.org
Subject: [PATCH] Preserve echo area contents when decoding an empty key
 sequence (Bug#33749)
Date: Sun, 16 Dec 2018 15:29:57 +0700
Message-Id: <20181216082957.13445-1-yuri.v.khan@HIDDEN>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <CAP_d_8V-pR=wfQw+9-ipun5_Xe2CfURGdXSoqUm+CAU-914VOA@HIDDEN>
References: <CAP_d_8V-pR=wfQw+9-ipun5_Xe2CfURGdXSoqUm+CAU-914VOA@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 33749
Cc: Yuri Khan <yuri.v.khan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* src/keyboard.h (struct kboard): New terminal-local variable
  `input-decode-preserve-echo'.

* src/keyboard.c (read_key_sequence): If the current sequence is
  mapped via `input-decode-map' to an empty sequence and
  `input-decode-preserve-echo' is non-nil, return -1.

* src/keyboard.c (command_loop_1): Save echo area contents before
  calling `read-key-sequence'. If it returns -1 and
  `input-decode-preserve-echo' is non-nil, restore echo area contents.
---
 src/keyboard.c | 27 ++++++++++++++++++++++++++-
 src/keyboard.h |  9 +++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index baf2f514409..70390ccf88c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1239,6 +1239,7 @@ command_loop_1 (void)
   EMACS_INT prev_modiff = 0;
   struct buffer *prev_buffer = NULL;
   bool already_adjusted = 0;
+  volatile Lisp_Object previous_echo_area_message;
 
   kset_prefix_arg (current_kboard, Qnil);
   kset_last_prefix_arg (current_kboard, Qnil);
@@ -1341,6 +1342,7 @@ command_loop_1 (void)
       Vthis_original_command = Qnil;
       Vthis_command_keys_shift_translated = Qnil;
 
+      previous_echo_area_message = Fcurrent_message ();
       /* Read next key sequence; i gets its length.  */
       raw_keybuf_count = 0;
       Lisp_Object keybuf[READ_KEY_ELTS];
@@ -1362,6 +1364,9 @@ command_loop_1 (void)
 	 Just loop around and read another command.  */
       if (i == -1)
 	{
+	  if (! NILP (KVAR (current_kboard, Vinput_decode_preserve_echo))
+	      && ! NILP (previous_echo_area_message))
+	    message_with_string ("%s", previous_echo_area_message, 0);
 	  cancel_echoing ();
 	  this_command_key_count = 0;
 	  this_single_command_key_start = 0;
@@ -8787,7 +8792,9 @@ void init_raw_keybuf_count (void)
    storing it in KEYBUF, a buffer of size READ_KEY_ELTS.
    Prompt with PROMPT.
    Return the length of the key sequence stored.
-   Return -1 if the user rejected a command menu.
+   Return -1 if the user rejected a command menu, or
+   `input-decode-preserve-echo' is non-nil and the user entered
+   a sequence that is mapped via `input-decode-map' to an empty vector.
 
    Echo starting immediately unless `prompt' is 0.
 
@@ -9540,6 +9547,9 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
 	  if (done)
 	    {
 	      mock_input = diff + max (t, mock_input);
+	      if (! NILP (KVAR (current_kboard, Vinput_decode_preserve_echo))
+		  && mock_input == 0)
+		return -1;
 	      goto replay_sequence;
 	    }
 	}
@@ -10817,6 +10827,7 @@ init_kboard (KBOARD *kb, Lisp_Object type)
   kset_system_key_syms (kb, Qnil);
   kset_window_system (kb, type);
   kset_input_decode_map (kb, Fmake_sparse_keymap (Qnil));
+  kset_input_decode_preserve_echo (kb, Qnil);
   kset_local_function_key_map (kb, Fmake_sparse_keymap (Qnil));
   Fset_keymap_parent (KVAR (kb, Vlocal_function_key_map), Vfunction_key_map);
   kset_default_minibuffer_frame (kb, Qnil);
@@ -11644,6 +11655,19 @@ and its return value (a key sequence) is used.
 The events that come from bindings in `input-decode-map' are not
 themselves looked up in `input-decode-map'.  */);
 
+  DEFVAR_KBOARD ("input-decode-preserve-echo", Vinput_decode_preserve_echo,
+                 doc: /* Preserve the echo area contents while decoding input.
+
+It is possible for `input-decode-map' to map a sequence to an empty vector,
+for example, to ignore irrelevant sequences sent by the terminal.
+
+If this variable is `nil', `read-key-sequence' will loop waiting for the
+sequence to continue.  The echo area may show the original sequence.  This
+is the historic Emacs behavior.
+
+If this variable is set to `t', `read-key-sequence' will return -1, and
+the command loop will restore the echo area contents.  */);
+
   DEFVAR_LISP ("function-key-map", Vfunction_key_map,
                doc: /* The parent keymap of all `local-function-key-map' instances.
 Function key definitions that apply to all terminal devices should go
@@ -11956,6 +11980,7 @@ mark_kboards (void)
       mark_object (KVAR (kb, system_key_syms));
       mark_object (KVAR (kb, Vwindow_system));
       mark_object (KVAR (kb, Vinput_decode_map));
+      mark_object (KVAR (kb, Vinput_decode_preserve_echo));
       mark_object (KVAR (kb, Vlocal_function_key_map));
       mark_object (KVAR (kb, Vdefault_minibuffer_frame));
       mark_object (KVAR (kb, echo_string));
diff --git a/src/keyboard.h b/src/keyboard.h
index ce4630b8a37..7c778292f50 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -151,6 +151,10 @@ struct kboard
        DEFVAR for more documentation.  */
     Lisp_Object Vinput_decode_map_;
 
+    /* Save and restore the echo area across sequences that are mapped
+       to the empty vector by `input-decode-map'.  */
+    Lisp_Object Vinput_decode_preserve_echo_;
+
     /* Minibufferless frames on this display use this frame's minibuffer.  */
     Lisp_Object Vdefault_minibuffer_frame_;
 
@@ -197,6 +201,11 @@ kset_input_decode_map (struct kboard *kb, Lisp_Object val)
   kb->Vinput_decode_map_ = val;
 }
 INLINE void
+kset_input_decode_preserve_echo (struct kboard *kb, Lisp_Object val)
+{
+  kb->Vinput_decode_preserve_echo_ = val;
+}
+INLINE void
 kset_last_command (struct kboard *kb, Lisp_Object val)
 {
   kb->Vlast_command_ = val;
-- 
2.20.1





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 15 Dec 2018 09:10:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 15 04:10:08 2018
Received: from localhost ([127.0.0.1]:48952 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gY5xY-0004pz-Ji
	for submit <at> debbugs.gnu.org; Sat, 15 Dec 2018 04:10:08 -0500
Received: from eggs.gnu.org ([208.118.235.92]:47951)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1gY5xX-0004pf-Hk
 for 33749 <at> debbugs.gnu.org; Sat, 15 Dec 2018 04:10:07 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1gY5xP-0008Ah-7J
 for 33749 <at> debbugs.gnu.org; Sat, 15 Dec 2018 04:10:02 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43512)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1gY5xP-0008AW-11; Sat, 15 Dec 2018 04:09:59 -0500
Received: from [176.228.60.248] (port=3130 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1gY5xO-0001cE-KP; Sat, 15 Dec 2018 04:09:58 -0500
Date: Sat, 15 Dec 2018 11:09:58 +0200
Message-Id: <83efajf95l.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yuri Khan <yurivkhan@HIDDEN>
In-reply-to: <CAP_d_8V-pR=wfQw+9-ipun5_Xe2CfURGdXSoqUm+CAU-914VOA@HIDDEN>
 (message from Yuri Khan on Sat, 15 Dec 2018 15:07:03 +0700)
Subject: Re: bug#33749: 26.1; input-decode-map to empty vector should preserve
 echo area
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <83imzvff9w.fsf@HIDDEN>
 <CAP_d_8V-pR=wfQw+9-ipun5_Xe2CfURGdXSoqUm+CAU-914VOA@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

> From: Yuri Khan <yurivkhan@HIDDEN>
> Date: Sat, 15 Dec 2018 15:07:03 +0700
> Cc: 33749 <at> debbugs.gnu.org
> 
> Okay. So, amended proposed course:
> 
> * Add a variable such as ‘input-decode-preserve-echo’, boolean,
> default nil, that controls the following behavior changes.
> 
> [any better ideas on the naming?]
> 
> * If the above variable is true
> > > and ‘read_key_sequence’ detects that the whole key sequence has been
> > > rewritten to an empty sequence, return -1.
> > >
> > > * In ‘command_loop_1’, save the echo area contents before calling
> > > ‘read_key_sequence’.
> Afterwards, if ‘input-decode-preserve-echo’ is true and the return
> value is -1, restore the echo area contents.
> 
> * In the future ‘terminal-init-xterm-kitty’ function, set
> ‘input-decode-preserve-echo’ to true when full keyboard mode is
> requested.

SGTM, but let's hear what others think.

> An alternative way could be to add hooks at start of
> ‘read_key_sequence’ and at each each sequence rewrite, but IMO that
> would be excessive.

I think I agree.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 15 Dec 2018 08:07:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 15 03:07:23 2018
Received: from localhost ([127.0.0.1]:48934 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gY4yp-0003Lr-78
	for submit <at> debbugs.gnu.org; Sat, 15 Dec 2018 03:07:23 -0500
Received: from mail-ot1-f42.google.com ([209.85.210.42]:43686)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1gY4yn-0003Lb-3w
 for 33749 <at> debbugs.gnu.org; Sat, 15 Dec 2018 03:07:21 -0500
Received: by mail-ot1-f42.google.com with SMTP id a11so7687923otr.10
 for <33749 <at> debbugs.gnu.org>; Sat, 15 Dec 2018 00:07:21 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc:content-transfer-encoding;
 bh=SQuZcD/VwmWHdvaiEoH3mL/QTR1bZrm1Cm4Dj8XmMTI=;
 b=UXWHVTIXvE8sSSRgAGV0S1De2wkVsdf7fidAMUPvuPY4KO/CrRwo0kNrB8SajhHVH9
 NAF/PrXTCQXqJLd+rVMX9c2H0EXFO/Dd1rdKv0txmRHI5Tc9f0BZ2wHeyU4r5RkRkzUC
 aoheiHGAtc5ciH9R+3pPezYHuWnmdY5Z1umffFW+2FWDDRRhdeTr3erwdObyOIp5Q6UR
 RDLmd2s/XgxaEamdd+be0ldgO62agOTo2QZ+zAfIK9BovGCzgVbOnOIx4Ev4WZgWGtvj
 Zt0DG9pvM5q4HPoZgqtjXnEHOLB/q4oJxvuSGsAU9BYT57Ycpqq/S++yADM5r/ylrgZ6
 9jUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc:content-transfer-encoding;
 bh=SQuZcD/VwmWHdvaiEoH3mL/QTR1bZrm1Cm4Dj8XmMTI=;
 b=CHvv4RIFwKpYXCCDE0uvV5MqO2gXIPM4t/PNEaB8ja8FKvs/SXCoHRP3tZ/epVcy28
 4x6/wcltYvYHuKFR8O7kNDxcflVfbKO3rqAGGzpO7ggFzO9UJbiX2y9SbquWP08whocr
 6z4NkvTIrkP7KbshaZYJEGdwpC6SS8A0JRZtWfE7FHOnO5fly+AJDRtD1Sp0sLGyfZEh
 3p5Sli8J8crFWIw2D3NoG3Aagw9yQdJ1YwWexTzOwPv90xa5PKKQiopow+auCt0H0f4V
 7taXhlARvyd3xehHl/f3vx0w/2WjMnl33bNrQuKq8Llym/Cx5RcGpiVpuOiHUCrJQsmp
 tCQA==
X-Gm-Message-State: AA+aEWYvd+MJ+zSza9rYR3T0Z87D+DcFWJSuD6Pnj/9EUI6miyPh0Yye
 0eGFQym0ODcMNO2kP6HSnLO/1u7odiQt5SYoL0Oa8IPO
X-Google-Smtp-Source: AFSGD/WNneJONevNHDeNq+CPkgY0PRZzeGvnw4i4pSB0BXnVMZHtEhaVVtZOKE2xJgo5AK4z0vPiB3G2XJedB2LCyXg=
X-Received: by 2002:a9d:4a87:: with SMTP id i7mr4343752otf.178.1544861235523; 
 Sat, 15 Dec 2018 00:07:15 -0800 (PST)
MIME-Version: 1.0
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 <83imzvff9w.fsf@HIDDEN>
In-Reply-To: <83imzvff9w.fsf@HIDDEN>
From: Yuri Khan <yurivkhan@HIDDEN>
Date: Sat, 15 Dec 2018 15:07:03 +0700
Message-ID: <CAP_d_8V-pR=wfQw+9-ipun5_Xe2CfURGdXSoqUm+CAU-914VOA@HIDDEN>
Subject: Re: bug#33749: 26.1; input-decode-map to empty vector should preserve
 echo area
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Dec 15, 2018 at 1:58 PM Eli Zaretskii <eliz@HIDDEN> wrote:

> [=E2=80=A6] if you want to propose a new feature in this area, I very
> much prefer to trigger such a feature by some (new) variable that is
> bound to a special value, rather than base the feature on decisions
> made by some modified logic.  Doing this by such a variable might be
> slightly less elegant and general, but OTOH it runs a much lower risk
> of causing unintended consequences elsewhere.

Okay. So, amended proposed course:

* Add a variable such as =E2=80=98input-decode-preserve-echo=E2=80=99, bool=
ean,
default nil, that controls the following behavior changes.

[any better ideas on the naming?]

* If the above variable is true
> > and =E2=80=98read_key_sequence=E2=80=99 detects that the whole key sequ=
ence has been
> > rewritten to an empty sequence, return -1.
> >
> > * In =E2=80=98command_loop_1=E2=80=99, save the echo area contents befo=
re calling
> > =E2=80=98read_key_sequence=E2=80=99.
Afterwards, if =E2=80=98input-decode-preserve-echo=E2=80=99 is true and the=
 return
value is -1, restore the echo area contents.

* In the future =E2=80=98terminal-init-xterm-kitty=E2=80=99 function, set
=E2=80=98input-decode-preserve-echo=E2=80=99 to true when full keyboard mod=
e is
requested.


An alternative way could be to add hooks at start of
=E2=80=98read_key_sequence=E2=80=99 and at each each sequence rewrite, but =
IMO that
would be excessive.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at 33749 <at> debbugs.gnu.org:


Received: (at 33749) by debbugs.gnu.org; 15 Dec 2018 06:58:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 15 01:58:02 2018
Received: from localhost ([127.0.0.1]:48896 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gY3ti-0001cU-DD
	for submit <at> debbugs.gnu.org; Sat, 15 Dec 2018 01:58:02 -0500
Received: from eggs.gnu.org ([208.118.235.92]:49022)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1gY3tg-0001bz-3O
 for 33749 <at> debbugs.gnu.org; Sat, 15 Dec 2018 01:58:00 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1gY3tV-0005qI-MZ
 for 33749 <at> debbugs.gnu.org; Sat, 15 Dec 2018 01:57:54 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41683)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1gY3tV-0005q7-Ij; Sat, 15 Dec 2018 01:57:49 -0500
Received: from [176.228.60.248] (port=2333 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1gY3tT-00031N-VR; Sat, 15 Dec 2018 01:57:49 -0500
Date: Sat, 15 Dec 2018 08:57:47 +0200
Message-Id: <83imzvff9w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yuri Khan <yurivkhan@HIDDEN>
In-reply-to: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
 (message from Yuri Khan on Sat, 15 Dec 2018 03:48:00 +0700)
Subject: Re: bug#33749: 26.1;
 input-decode-map to empty vector should preserve echo area
References: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33749
Cc: 33749 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

> From: Yuri Khan <yurivkhan@HIDDEN>
> Date: Sat, 15 Dec 2018 03:48:00 +0700
> 
> The call sequence that causes the echo to be cleared looks like this:
> 
> command_loop_1 (in keyboard.c)
>   read_key_sequence
>     read_char
>       redisplay
> 
> and much of the read_char and read_key_sequence mechanics maintain
> echoing of the current prefix sequence.
> 
> 
> My suggestion is to add two changes:
> 
> * If ‘read_key_sequence’ detects that the whole key sequence has been
> rewritten to an empty sequence, return -1. This is the same code as a
> canceled menu selection, upon receiving which clients call
> ‘read_key_sequence’ again.
> 
> * In ‘command_loop_1’, save the echo area contents before calling
> ‘read_key_sequence’, and restore it if the return value is -1.

Thanks for digging into this issue.

Based on bitter past experience, I generally would like to avoid
changes in these low-level mechanisms based on analysis of the code's
logic and their presumed semantics.  We had quite a few of cases where
such analyses seemed sound when they were presented, but later turned
out to miss some more or less rare situations and use cases, and
changes based on such analyses thus caused subtle bugs that were hard
or even impossible to fix without reverting to the old code (and
losing the improvements provided by the new code).

Therefore, if you want to propose a new feature in this area, I very
much prefer to trigger such a feature by some (new) variable that is
bound to a special value, rather than base the feature on decisions
made by some modified logic.  Doing this by such a variable might be
slightly less elegant and general, but OTOH it runs a much lower risk
of causing unintended consequences elsewhere.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Dec 2018 22:25:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 14 17:25:45 2018
Received: from localhost ([127.0.0.1]:48633 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gXvtv-0003jS-9I
	for submit <at> debbugs.gnu.org; Fri, 14 Dec 2018 17:25:45 -0500
Received: from eggs.gnu.org ([208.118.235.92]:51232)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yurivkhan@HIDDEN>) id 1gXuNo-0001Rq-3C
 for submit <at> debbugs.gnu.org; Fri, 14 Dec 2018 15:48:28 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1gXuNh-0006x5-5M
 for submit <at> debbugs.gnu.org; Fri, 14 Dec 2018 15:48:22 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:55668)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <yurivkhan@HIDDEN>) id 1gXuNe-0006vJ-PC
 for submit <at> debbugs.gnu.org; Fri, 14 Dec 2018 15:48:19 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60837)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1gXuNd-00017y-8S
 for bug-gnu-emacs@HIDDEN; Fri, 14 Dec 2018 15:48:18 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <yurivkhan@HIDDEN>) id 1gXuNb-0006ng-Hv
 for bug-gnu-emacs@HIDDEN; Fri, 14 Dec 2018 15:48:17 -0500
Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:44558)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <yurivkhan@HIDDEN>) id 1gXuNb-0006bt-9V
 for bug-gnu-emacs@HIDDEN; Fri, 14 Dec 2018 15:48:15 -0500
Received: by mail-ot1-x341.google.com with SMTP id f18so6657203otl.11
 for <bug-gnu-emacs@HIDDEN>; Fri, 14 Dec 2018 12:48:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=DYqX8HlmR3BOQ1p9sP0yNIsMMOwqdE3luEiAODKJlp8=;
 b=WQFGxcjR248WM4WBUHmZcRCNWjvPZUlRZdNuFchMvEPoFJZ2wzjTx2w8h7qWJQ9EBH
 MRMRo7aeItwvOLMd5MgNmbd63JacSLbLxZoWnTBWJx7l0CGqKaV19GoBdvab8lpAweIC
 4gC/x0VJbT6k5tuZqHKD6Uw8wLTsFNLPE5vdJzL2nW2i8OLBLsKZ9eyxZH3cza6WaxZE
 2Mcb39moOmhA+1DUHyB7MgfqfZFJwjNftTlBRAn+60TZG4b5NjbaNZCOK11l36bJ/VbM
 4rJ9dWRbXEPm5RqqQPH1XZrofOWGsiM4llpfS3jpqLXz2Islm5u2DbZkzd+h7ECT/fGq
 yUTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to
 :content-transfer-encoding;
 bh=DYqX8HlmR3BOQ1p9sP0yNIsMMOwqdE3luEiAODKJlp8=;
 b=A7fyHgDnl5O/4cdM0FA8rfvjvDjhhxHAkjiR654sdGtA6EaigLwX1+6Nh+dJIhVcfB
 2zgIuMX5+T3dg9wGtmpb/7J2o3S8T6dxbQfJycNfdomUM4BNrnpFeU4uXnT8S1cylYZj
 etSgoQ56GkPuwfgye5ZunrEy2CGttEaQanis1ZaNKBwtmTgxW/OosxUZYsUJUjzHMTOq
 CDfypWsbadnaUdCx9IDVghs/C/HakVF/BNJEUJH03waJhJPvtEhNxYjaGpzE4SGuZgvB
 iZC27ehjiHkani2LOQ+aJQjNocNUN5cJcvfE5OJ7GNSPSXN9rqf94gMmqlLGlwC2DyId
 DqDw==
X-Gm-Message-State: AA+aEWYJ80iABLdeHa/CY3OF1p5LhqWMnD0DPnm4gPs78mVOko4eJnXw
 ZZCAIgIDeXhITKP4zK1rtQwtStKtEix1X1VzPSXoLmLV
X-Google-Smtp-Source: AFSGD/Vab8WmnhpGcE5MVgWNSELo6AaIOBJeVUnMlVdpOcgfoyJjqvgbzUFwN4TN3So9tOF1B49GMiWiKO7W2Svjp6A=
X-Received: by 2002:a9d:6419:: with SMTP id h25mr3373502otl.34.1544820492729; 
 Fri, 14 Dec 2018 12:48:12 -0800 (PST)
MIME-Version: 1.0
From: Yuri Khan <yurivkhan@HIDDEN>
Date: Sat, 15 Dec 2018 03:48:00 +0700
Message-ID: <CAP_d_8XMu1aCTV8RGO-6exMbYsie2VNP-P_x3Y4t91DbJSM1Bw@HIDDEN>
Subject: 26.1; input-decode-map to empty vector should preserve echo area
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 14 Dec 2018 17:25:42 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

See wider context here:
http://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00254.html

The Kitty terminal emulator in full keyboard mode sends sequences for
every keyboard event. This includes key release events and modifier
key press events. I would like to ignore these, and it seems to be the
most appropriate method to map them to an empty vector via
=E2=80=98input-decode-map=E2=80=99. Currently, this works, but every time s=
uch a
sequence is received from the terminal, the echo area is cleared,
rendering invisible any prompt displayed by the previous key press.


Here=E2=80=99s a playground recipe with no external dependencies:

$ emacs -Q

(define-key input-decode-map (kbd "<f5> <f5>") [])

C-s <f5> <f5>


The intuitive expectation is that pressing <f5> <f5> is a no-op. The
I-search prompt should continue to be displayed, and no other action
should be taken.

The actual behavior depends on the timing:

* Pressing <f5> the first time clears the echo area immediately.

* If <f5> is pressed again within =E2=80=98echo-keystrokes=E2=80=99 seconds=
, the echo
area stays blank and the prompt invisible until the next key (other
than <f5>) is pressed.

* If =E2=80=98echo-keystrokes=E2=80=99 seconds elapse before the next key i=
s pressed,
then the echo area displays the current key sequence prefix and a
dash: =E2=80=98f5-=E2=80=99.

* In that case, pressing <f5> again changes the echo area to =E2=80=98f5 f5=
-=E2=80=99,
as if it=E2=80=99s waiting for more. And it is; since <f5> <f5> is replaced=
 by
an empty vector, it is now a prefix of every possible binding.


The call sequence that causes the echo to be cleared looks like this:

command_loop_1 (in keyboard.c)
  read_key_sequence
    read_char
      redisplay

and much of the read_char and read_key_sequence mechanics maintain
echoing of the current prefix sequence.


My suggestion is to add two changes:

* If =E2=80=98read_key_sequence=E2=80=99 detects that the whole key sequenc=
e has been
rewritten to an empty sequence, return -1. This is the same code as a
canceled menu selection, upon receiving which clients call
=E2=80=98read_key_sequence=E2=80=99 again.

* In =E2=80=98command_loop_1=E2=80=99, save the echo area contents before c=
alling
=E2=80=98read_key_sequence=E2=80=99, and restore it if the return value is =
-1.

A proposed patch will follow.


In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-05-29 built on lcy01-amd64-029
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description:    Ubuntu 18.04.1 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
[]
Quit
Configured using:
 'configure --build=3Dx86_64-linux-gnu --prefix=3D/usr
 '--includedir=3D${prefix}/include' '--mandir=3D${prefix}/share/man'
 '--infodir=3D${prefix}/share/info' --sysconfdir=3D/etc --localstatedir=3D/=
var
 --disable-silent-rules '--libdir=3D${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=3D${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=3D/usr --sharedstatedir=3D/var/lib
 --program-suffix=3D26 --with-modules --with-file-notification=3Dinotify
 --with-mailutils --with-x=3Dyes --with-x-toolkit=3Dgtk3 --with-xwidgets
 --with-lcms2 'CFLAGS=3D-g -O2
 -fdebug-prefix-map=3D/build/emacs26-pCvJBp/emacs26-26.1~1.git07f8f9b=3D.
-fstack-protector-strong
 -Wformat -Werror=3Dformat-security -no-pie' 'CPPFLAGS=3D-Wdate-time
 -D_FORTIFY_SOURCE=3D2' 'LDFLAGS=3D-Wl,-Bsymbolic-functions -Wl,-z,relro
 -no-pie''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_MONETARY: en_RU.UTF-8
  value of $LC_NUMERIC: en_RU.UTF-8
  value of $LC_TIME: en_RU.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
easymenu mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils misearch multi-isearch edmacro kmacro
cl-loaddefs cl-lib elec-pair time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting xwidget-internal move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 96766 11934)
 (symbols 48 20584 1)
 (miscs 40 46 179)
 (strings 32 28973 1221)
 (string-bytes 1 760346)
 (vectors 16 14880)
 (vector-slots 8 498940 11302)
 (floats 8 50 266)
 (intervals 56 264 14)
 (buffers 992 11))




Acknowledgement sent to Yuri Khan <yurivkhan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#33749; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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