noctuid / evil-guide

Draft of a guide for using emacs with evil
GNU General Public License v3.0
1.26k stars 61 forks source link

Escape in emacs-state -- outdated info; suggested binding doesn't work in terminal #14

Closed jackkamm closed 5 years ago

jackkamm commented 5 years ago

The guide says the following:

In emacs state, C-z and ESC are bound to switch to the previous state.

This does not appear to be the case -- ESC acts like normal Meta in Emacs state by default.

Also, the suggestion on how to bind ESC in emacs-state only works in the GUI, but not in the terminal:

(define-key evil-emacs-state-map [escape] 'evil-normal-state)

Unfortunately, binding (kbd "ESC") overwrites Meta, and thus important keys like M-x, in the terminal. I would like a way for ESC in emacs-state to behave the same as in insert-state, but it's not clear to me if it's possible.

noctuid commented 5 years ago

This is the expected behavior. ESC and meta normally behave same in terminal Emacs. Evil handles escape specially which is why it works in insert state in the terminal. There is actually an explicit check in the code to prevent this functionality in emacs state it seems (see here). I'd recommended opening an issue on evil requesting that it optionally support emacs state as well.

jackkamm commented 5 years ago

Thanks for the link. I've found that (defalias 'evil-emacs-state 'evil-insert-state) accomplishes what I want (I also use evil-disable-insert-state-bindings), so for now won't make a feature request on evil.

I should note that the statement that ESC is bound to evil-exit-emacs-state appears to be false, even in the GUI -- I think my wording was ambiguous there.

noctuid commented 5 years ago

Yes, there were some typos/errors about evil-toggle-key. I've fixed them.