2

我从 emacs 网站获取了以下代码作为邪恶 -

(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")

它设置了 Cc 键以从插入模式中转义。如何将其更改为更方便的键弦,例如 "tt" ?

我使用了以下 -

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

但是,当我在插入模式下按“tt”时,它会在迷你缓冲区中提供以下消息 -

<key-chord> <escape> is undefined
4

1 回答 1

4

我无法重现您的错误,对我来说很好。确保您已安装 key-chord 软件包。

(require 'key-chord)(key-chord-mode 1) ; turn on key-chord-mode
(key-chord-define evil-insert-state-map "tt" 'evil-normal-state)
于 2013-10-03T09:52:15.440 回答