Subject: bug#50804: Command substitutions for keys without keymaps

From: Stefan Kangas <[email-masked]>
Date: Sat, 20 Nov 2021 16:05:54 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> The second one will be printed as "\‘C-h‘" on old versions, which isn't
>> perfect but not too bad.  Even if the extra "\" is distracting, it is at
>> least not actively misleading...
>
> That's a good point.  So perhaps \\`C-h' does make sense in
> `substitute-command-keys'.

I found a patch of mine from March that I had forgotten about.  It uses
the syntax "\\[=y]" to mean the key "y" where, I guess, we could
stipulate that whatever comes after "=" is `key-valid-p'.

However, it breaks backwards incompatibility just as "\\[[y]]" would:

    (substitute-command-keys "\\[=k]")
    => "M-x =k"

    (substitute-command-keys "\\[[y]]")
    => "M-x [y]"

Which is just... wrong.  So either we say that, you know, don't use this
syntax in code intended for use in anything older Emacs 29, or we just
go with the new syntax \\`y`.

Given that I have a seemingly mostly working patch it should be easy to
fix it up whichever way we decide to go.  I hope.