[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18182: 24.3.92; C-[ does not work as ESC in viper-mode
From: |
Stefan Monnier |
Subject: |
bug#18182: 24.3.92; C-[ does not work as ESC in viper-mode |
Date: |
Mon, 18 Aug 2014 22:22:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
> 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.
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).
When `escape' has no specific binding, Emacs remaps it to ESC (via
function-key-map), so previously the `escape' key worked to trigger the
ESC binding of Viper.
The C-[ key is an alias (at a lower level) for the ESC char, so indeed
now it doesn't work any more to trigger the "viper-ESC-key" behavior.
Actually it still works under a tty, since under a tty Viper receives
ESC (rather than `escape') when you hit the escape key, so it has
special code that maps this ESC to an `escape' (but only for tty frames,
not in GUI frames).
I think the hack below should work. Can you confirm it works for you?
Stefan
=== modified file 'lisp/emulation/viper.el'
--- lisp/emulation/viper.el 2014-06-29 02:33:50 +0000
+++ lisp/emulation/viper.el 2014-08-19 02:22:11 +0000
@@ -600,6 +600,9 @@
))
(viper-set-expert-level 'dont-change-unless)))
+ (if (equal viper-ESC-key [escape])
+ (define-key function-key-map [?\e] [escape]))
+
(or (memq major-mode viper-emacs-state-mode-list) ; don't switch to Vi
(memq major-mode viper-insert-state-mode-list) ; don't switch
(viper-change-state-to-vi))