【问题标题】:binding the escape key to a keychord for evil-mode将转义键绑定到邪恶模式的键弦
【发布时间】:2013-10-03 02:55:05
【问题描述】:

我已经从 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")

它为退出插入模式设置了 C-c 键。如何将其更改为更方便的键和弦,例如“tt”?

我使用了以下 -

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

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

<key-chord> <escape> is undefined

【问题讨论】:

    标签: emacs evil-mode


    【解决方案1】:

    我无法重现您的错误,对我来说很好。 确保您已安装 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-27
      • 2023-04-11
      • 1970-01-01
      • 2014-05-17
      • 2014-03-28
      相关资源
      最近更新 更多