定义用于绑定evil-leader-key的匿名函数

时间:2016-05-24 12:37:28

标签: emacs evil-mode

使密钥t的绑定工作所需的语法是什么?

(evil-leader/set-key
  "f" 'find-file
  "o" 'other-window
  "b" 'switch-to-buffer
  "k" 'kill-buffer
  "1" 'delete-other-windows
  "2" 'split-window-below
  "3" 'split-window-right
  "c" 'winner-undo
  "w" 'enlarge-window-horizontally
  "t" (lambda () (enlarge-window 5))
  "d" 'ido-dired)

我尝试了多种变体,包括引用整个表达式,仅引用enlarge-window调用等。也许你不能这样做?

1 个答案:

答案 0 :(得分:2)

该功能需要具有互动性。 e.g。

(evil-leader/set-key
  ...
  "t" (lambda () (interactive) (enlarge-window 5)))

旁注:如果详细程度有问题,这个宏可以修复:

(defmacro λ! (&rest body)
  `(lambda () (interactive) ,@body))

(evil-leader/set-key
  "t" (λ! (enlarge-window 5)))