質問

I have taken the below code from emacs site for evil -

(defun my-esc (prompt)
  "Functionality for escaping generally.  Includes exiting Evil insert state and C-g binding. "
  (cond
   ;; If we're in one of the Evil states that defines [escape] key, return [escape] so as
   ;; Key Lookup will use it.
   ((or (evil-insert-state-p) (evil-normal-state-p) (evil-replace-state-p) (evil-visual-state-p)) [escape])
   ;; This is the best way I could infer for now to have C-c work during evil-read-key.
   ;; Note: As long as I return [escape] in normal-state, I don't need this.
   ;;((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)
;; Works around the fact that Evil uses read-event directly when in operator state, which
;; doesn't use the key-translation-map.
(define-key evil-operator-state-map (kbd "C-c") 'keyboard-quit)
;; Not sure what behavior this changes, but might as well set it, seeing the Elisp manual's
;; documentation of it.
(set-quit-char "C-c")

It sets up the C-c key for escaping from the insert mode. How do I change it to a more convenient keychord such as "tt" ?

I used the below -

(key-chord-define evil-insert-state-map "tt" 'evil-normal-state)

However when I press 'tt' in the insert mode, it gives the following msg in the mini buffer -

<key-chord> <escape> is undefined
役に立ちましたか?

解決

I couldn't reproduce your error, works fine for me. Make sure you have the key-chord package installed.

(require 'key-chord)(key-chord-mode 1) ; turn on key-chord-mode
(key-chord-define evil-insert-state-map "tt" 'evil-normal-state)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top