2013-10-03 115 views
1

一個keychord我已經採取了下面的代碼從Emacs的邪惡 -結合ESC鍵爲邪惡的模式

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

它設置爲從插入模式逃避C-C鍵。如何將其更改爲更方便的按鍵,如「tt」?

我用下面的 -

(鍵弦限定惡插入狀態圖「TT」「惡正常狀態)

然而,當我按」 TT '在插入模式下,它在迷你緩衝區中給出以下消息 -

<key-chord> <escape> is undefined 

回答

3

我無法重現您的錯誤,對我來說工作正常。 確保您安裝了和絃鍵盤包。

(require 'key-chord)(key-chord-mode 1) ; turn on key-chord-mode 
(key-chord-define evil-insert-state-map "tt" 'evil-normal-state)