使用使用包解除绑定键


10

我正在尝试取消绑定 org-cycle-agenda-files,默认情况下设置为 C-'C-,

我选择这样做的武器是use-package package。

github.com/use-package/bind-key.el 页面上,我发现了以下几行:

;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;
;;   (unbind-key "c-c x" some-other-mode-map)

这导致我尝试以下变体失败:

(unbind-key "C-'" )
(unbind-key "C-," )
(unbind-key "C-'" (org-cycle-agenda-files))
(unbind-key "C-," (org-cycle-agenda-files))
(bind-keys :map org-mode-map
       :unbind "C-'")
(unbind-key "C-'" org-cycle-agenda-files)

失败之后,我尝试了一些“传统”解决方案。

gnu.org手册中找到的信息以及一些emacs.stackexchange答案导致我产生了以下无用的破坏:

(define-key (org-cycle-agenda-files) key nil)
(define-key (current-global-map) "C-'" nil)
(local-unset-key "C-'")
(global-unset-key "C-'")
(with-eval-after-load org-mode
  (unbind-key "C-'" org-mode-map)
  (unbind-key "C-," org-mode-map))
(global-set-key (kbd "C-'") 'nil)

是的....这些变化都没有。:D

我很想找到基于使用包的解决方案,因为我已经在使用其中一些很棒的功能。

任何建议都是值得欢迎的。

Answers:


14

如果C-h f输入unbind-key,则帮助将显示:

unbind-key是`bind-key.el'中的一个自动加载的Lisp宏。

(解除绑定的键名和可选的KEYMAP)

没有记录。

的第二个参数unbind-key是键映射-例如org-mode-map

这对我有用:

(require 'bind-key)
(unbind-key "C-," org-mode-map)
(unbind-key "C-'" org-mode-map)

一个合适的地方:configuse-package表格的一部分。


4

是的,解除绑定看起来并不优雅,但这是根据此答案的主要方法。

至于使用包,我一直在:init指令下使用unbind,如下所示:

:init
(unbind-key "C-'" org-mode-map)
(unbind-key "C-," org-mode-map)

您需要将其放进:config,而不是放进去:init,因为键图中:init可能尚未加载。
ギョーム
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.