Subject: bug#18182: 24.3.92; C-[ does not work as ESC in viper-mode

From: Stefan Monnier <[email-masked]>
Date: Wed, 09 Sep 2020 09:50:37 -0400

>>> The following steps reproduce the problem.
>>> 1. Run "emacs -Q".
>>> 2. Type "M-x viper" to enable viper-mode.
>>> 3. Type "i" to enter viper insert mode.
>>> 4. Type "C-[".
>>
>>> On Emacs 24.3, it exits from viper insert mode as well as ESC key does.
>>> On Emacs 24.3.92, it displays "ESC-" in minibuffer and does not exit
>>> from viper insert mode.
>
> This problem is still present in Emacs 28.
>
>> In Emacs-24.4, Viper's escape key sequence (in viper-ESC-key) was
>> changed from [?\e] to [escape], i.e. from the ASCII escape char (usually
>> called ESC in Emacs) to the `escape' key (usually called `escape' in
>> Emacs).
>
> I had a look to see what the point of the change was, but the commit
> helpfully says:
>
>             * viper-keym.el (viper-ESC-key): constant changed (Stefan Monnier's
>             patch).
>
> Stefan?  Would it make sense to change it back to ?\e again?

IIRC this had to do with the code that distinguishes "ESC the key" from
"ESC the prefix in escape sequences" on ttys.  The patch basically
changes input-decode-map to turn ESC into `escape` if there's no other
input after a short timeout.

But maybe we can keep using `ESC`, by relying on the function-key-map to
map `escape` back to `ESC`.

        Stefan