Issue #2 resolved

Meta-key in terminal does not work

Frank Fischer
repo owner created an issue

Key-bindings involving a meta-key, e.g., M-x, do not work in terminal mode. The reason is that the (kbd "ESC") binding is overwritten in evil-maps.el, but all bindings with meta-key in terminal mode are signalled with ESC as prefix key.

Therefore some special magic has to be done intercepting the ESC key when used as prefix-key. viper and vim-mode both do this using some special key-binding on ESC with timeout (look for //vim:intercept-ESC-mode// in //vim-keymap.el// of vim-mode's source).

Furthermore, in X mode it may be better to bind [escape] instead of "ESC" (in fact, the signal arriving from the system is [escape] which is converted to "ESC") and leave the "ESC" binding unchanged. This way the Emacs alternative of pressing "ESC x" instead of "M-x" should work in X mode, too (in X "M-x" and "ESC x" are different events but the first is eventually remapped to the second, in terminal mode both events are the same, namely "ESC x").

Comments (4)

  1. Vegard Øye

    We could create a dedicated keymap (with evil-define-keymap) and bind the interception command in it. Then we could add the interception keymap to the front :enable argument of the relevant states. Or, we could hard-code it into the evil-normalize-keymaps function, so that the interception keymap is always at the top of the evil-mode-map-alist variable.

    Probably the latter? Otherwise it's a potential problem in every state that binds ESC, or enables the keymaps of a state that does.

  2. Vegard Øye

    I adapted vim-mode's code in commit df0f290. ESC is now intercepted by the command evil-esc in every state except Emacs state. evil-esc is bound to (kbd "ESC"), while other commands are bound to [escape]. This means that evil-esc is seen only in the terminal, where (kbd "ESC") and [escape] are the same event.

  3. Log in to comment