GNU bug report logs - #52448
key-valid-p vs "C-M-x" and "ESC C-x"

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefan <at> marxist.se>

Date: Sun, 12 Dec 2021 08:18:02 UTC

Severity: normal

To reply to this bug, email your comments to 52448 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#52448; Package emacs. (Sun, 12 Dec 2021 08:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Kangas <stefan <at> marxist.se>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 12 Dec 2021 08:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: bug-gnu-emacs <at> gnu.org
Subject: key-valid-p vs "C-M-x" and "ESC C-x"
Date: Sun, 12 Dec 2021 00:17:48 -0800
AFAIU, we want exactly one valid way to write keybindings with
`key-valid-p'.  Should both of these be `key-valid-p'?

1.  (key-description (kbd "ESC C-x"))
    => "C-M-x"

    (key-valid-p "ESC C-x")
    => t

2.  (key-description (kbd "C-M-x"))
    => "C-M-x"

    (key-valid-p "C-M-x")
    => t

However, there is also this, and the comment at the top of keymap.c:

    (kbd "ESC C-x")
    => "^[^X"

    (kbd "M-C-x")
    => [134217752]




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52448; Package emacs. (Sun, 12 Dec 2021 08:28:02 GMT) Full text and rfc822 format available.

Message #8 received at 52448 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 52448 <at> debbugs.gnu.org
Subject: Re: bug#52448: key-valid-p vs "C-M-x" and "ESC C-x"
Date: Sun, 12 Dec 2021 09:27:03 +0100
Stefan Kangas <stefan <at> marxist.se> writes:

> AFAIU, we want exactly one valid way to write keybindings with
> `key-valid-p'.  Should both of these be `key-valid-p'?
>
> 1.  (key-description (kbd "ESC C-x"))
>     => "C-M-x"
>
>     (key-valid-p "ESC C-x")
>     => t

That's what happens today, but Stefan M had a cunning plan to make
round-tripping these keystrokes (EST/TAB/RET) work better.

In that case

"ESC C-x"

and

"C-M-x"

would still both be valid, but refer to different things (that get
resolved to the same thing).

But we're not there today, so when writing keymaps one should use the
intended mnemonics.  For instance, it's

  "C-c C-i" #'gnus-info-find-node

and not

  "C-c TAB" #'gnus-info-find-node

because the "i" is for "info".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52448; Package emacs. (Mon, 13 Dec 2021 13:34:01 GMT) Full text and rfc822 format available.

Message #11 received at 52448 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 52448 <at> debbugs.gnu.org
Subject: Re: bug#52448: key-valid-p vs "C-M-x" and "ESC C-x"
Date: Mon, 13 Dec 2021 05:33:10 -0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Stefan Kangas <stefan <at> marxist.se> writes:
>
>> AFAIU, we want exactly one valid way to write keybindings with
>> `key-valid-p'.  Should both of these be `key-valid-p'?
>>
>> 1.  (key-description (kbd "ESC C-x"))
>>     => "C-M-x"
>>
>>     (key-valid-p "ESC C-x")
>>     => t
>
> That's what happens today, but Stefan M had a cunning plan to make
> round-tripping these keystrokes (EST/TAB/RET) work better.
>
> In that case
>
> "ESC C-x"
>
> and
>
> "C-M-x"
>
> would still both be valid, but refer to different things (that get
> resolved to the same thing).

So both will be valid even with the planned changes, and this is
notabug?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52448; Package emacs. (Mon, 13 Dec 2021 23:19:01 GMT) Full text and rfc822 format available.

Message #14 received at 52448 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 52448 <at> debbugs.gnu.org
Subject: Re: bug#52448: key-valid-p vs "C-M-x" and "ESC C-x"
Date: Tue, 14 Dec 2021 00:18:29 +0100
Stefan Kangas <stefan <at> marxist.se> writes:

> So both will be valid even with the planned changes, and this is
> notabug?

Yes, both will remain valid, but it's a bug that it's not round-tripping
properly, so the report might as well stay open until that's fixed.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#52448; Package emacs. (Tue, 14 Dec 2021 02:40:02 GMT) Full text and rfc822 format available.

Message #17 received at 52448 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 52448 <at> debbugs.gnu.org
Subject: Re: bug#52448: key-valid-p vs "C-M-x" and "ESC C-x"
Date: Mon, 13 Dec 2021 18:39:13 -0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Yes, both will remain valid, but it's a bug that it's not round-tripping
> properly, so the report might as well stay open until that's fixed.

OK.

I'm linking the emacs-devel thread where round-tripping was discussed:

    https://lists.gnu.org/archive/html/emacs-devel/2021-11/msg00941.html




This bug report was last modified 2 years and 127 days ago.

Previous Next


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