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

Define anonymous function for binding to evil-leader-key

绑定到键 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 调用和其他。也许你不能这样做?

功能需要交互。例如

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

旁注:如果冗长让您感到厌烦,这个宏可以解决这个问题:

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

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