key-translation-map not honored in Evil O state
Because C-c is one way of escaping in Vim, and because it is more ergonomic than C-g, I aim to use it for escaping insert state and keyboard-quit. I use this in my .emacs .
(defun my-esc (prompt) "Functionality for escaping generally. Includes exiting Evil insert state and C-g binding. " (cond ((or (evil-insert-state-p) (evil-motion-state-p)) [escape]) ;; This is the best way I could infer for now to have C-c work during evil-read-key. ((eq overriding-terminal-local-map evil-read-key-map) (keyboard-quit) (kbd "")) (t (kbd "C-g")))) (define-key key-translation-map (kbd "C-c") 'my-esc) (set-quit-char "C-c")
(As an aside, I've also created:
(define-key evil-motion-state-map "cc" mode-specific-map) so I have my own means of getting the usual keymap bound to C-c.)
I've found this works in all cases except when I'm in the Operator Pending state.
When I do:
= I enter the operator pending state and find
C-g successfully exits.
However, I find that when I use
C-c instead of
C-g, it doesn't keyboard-quit. The output in the minibuffer indicates it is using C-c for key lookup and finding it bound to another keymap (presumably the global one). Why is the key-translation-map not translating the C-c to C-g before the key lookup in this Evil state?
I get the behavior I seek when I put this in my .emacs:
(define-key evil-operator-state-map (kbd "C-c") 'keyboard-quit).