general.el 如何一次绑定两组快捷键到相同的函数?

没用过 GitHub - noctuid/general.el: More convenient key definitions in emacs 一下抓不到重点。

看到它有一个 :non-normal-prefix 关键字,跟我想要有点接近了,比如:

(general-define-key
 :keymaps '(normal insert emacs)
 :non-normal-prefix "M-o"
 "zc" #'evil-close-fold
 "zo" #'evil-open-fold
 "zm" #'hs-hide-level
 "zr" #'evil-open-folds
 ...)

这一段配置的效果是:

| \  | normal | insert       | emacs        |
|----|--------|--------------|--------------|
| fn | key    | prefix + key | prefix + key |
|    |        |              |              |

而我期望的是:

| \  | normal       | insert       | emacs        |
|----|--------------|--------------|--------------|
| fn | key          | prefix + key | prefix + key |
|    | prefix + key |              |              |

normal 状态下可以使用 keyprefix + key 两组快捷键。

应该如何设置?难道要针对 normal 重复一遍配置吗:

(general-define-key
 :keymaps '(normal)
 :prefix "M-o"
 "zc" #'evil-close-fold
 "zo" #'evil-open-fold
 "zm" #'hs-hide-level
 "zr" #'evil-open-folds
 ...)
1 个赞

最好是写一个macro

加一行 :prefix "M-o" 就可以了