如何从 Emacs 中的次要模式键盘映射中删除键?

发布于 2024-12-07 05:31:36 字数 257 浏览 1 评论 0原文

我已将 Cc/ 全局分配给 ace-jump-mode,但 reftex-mode(与 AucTeX 一起使用的引用的次要模式)用一些我从未使用过的功能覆盖了此键。

我尝试了 local-unset-key 但它仅从当前主要模式的地图中解除按键绑定。

如何在不更改 reftex.el 的情况下从 reftex-mode-map 中删除 Cc/

I have globally assigned C-c/ to ace-jump-mode but reftex-mode (a minor mode for citations used with AucTeX) overrides this key with some function I never use.

I tried local-unset-key but it only unbinds keys from the current major mode's map.

How do I remove C-c/ from reftex-mode-map without making changes to reftex.el?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我为君王 2024-12-14 05:31:36

您可以使用define-key更改现有的键映射。通过传递 nil 作为要调用的函数,键将变为未绑定。我想您应该能够执行以下操作:

(define-key reftex-mode-map "\C-c/" nil)

当然,您应该在某种挂钩中执行此操作,例如:

(defun my-reftex-hook ()
  (define-key reftex-mode-map "\C-c/" nil))
(add-hook 'reftex-mode-hook 'my-reftex-hook)

You can change an existing key map using define-key. By passing nil as the function to call, the key will become unbound. I guess that you should be able to do something like:

(define-key reftex-mode-map "\C-c/" nil)

Of course, you should do this in some kind of hook, for example:

(defun my-reftex-hook ()
  (define-key reftex-mode-map "\C-c/" nil))
(add-hook 'reftex-mode-hook 'my-reftex-hook)
与风相奔跑 2024-12-14 05:31:36

您可以使用以下命令:

(define-key reftex-mode-map "\C-c/" nil)

Cc / 取消映射此函数...但是应该加载 reftex-mode,因此 reftex-mode-map > 可进行修改

You can use following command:

(define-key reftex-mode-map "\C-c/" nil)

to unmap this function from C-c /... But reftex-mode should be loaded, so reftex-mode-map will available for modification

執念 2024-12-14 05:31:36

我就是这样做的。不过,它还可以改进。

 (defun get-key-combo (key)
  "Just return the key combo entered by the user"
  (interactive "kKey combo: ")
  key)

(defun keymap-unset-key (key keymap)
    "Remove binding of KEY in a keymap
    KEY is a string or vector representing a sequence of keystrokes."
    (interactive
     (list (call-interactively #'get-key-combo)
           (completing-read "Which map: " minor-mode-map-alist nil t)))
    (let ((map (rest (assoc (intern keymap) minor-mode-map-alist))))
      (when map
        (define-key map key nil)
        (message  "%s unbound for %s" key keymap))))
;;
;; Then use it interativly
;; Or like this:

(keymap-unset-key  '[C-M-left]   "paredit-mode")
..
..

This is how I do it. It could be improved, though.

 (defun get-key-combo (key)
  "Just return the key combo entered by the user"
  (interactive "kKey combo: ")
  key)

(defun keymap-unset-key (key keymap)
    "Remove binding of KEY in a keymap
    KEY is a string or vector representing a sequence of keystrokes."
    (interactive
     (list (call-interactively #'get-key-combo)
           (completing-read "Which map: " minor-mode-map-alist nil t)))
    (let ((map (rest (assoc (intern keymap) minor-mode-map-alist))))
      (when map
        (define-key map key nil)
        (message  "%s unbound for %s" key keymap))))
;;
;; Then use it interativly
;; Or like this:

(keymap-unset-key  '[C-M-left]   "paredit-mode")
..
..
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文