gpt4 book ai didi

emacs - 如何在本地模式中取消设置 map 中的键绑定(bind)?

转载 作者:行者123 更新时间:2023-12-02 21:28:40 25 4
gpt4 key购买 nike

我已经为修改 Emacs 自动完成行为的函数设置了键绑定(bind):

;; ISSUE: when I type the whole candidate string and then press [SPC], 
;; Emacs will insert two spaces.
(define-key ac-menu-map (kbd "SPC")
(defun ac-complete-with-space ()
"Select the candidate and append a space. Save your time for typing space."
(interactive)
(ac-complete)
;; FIXME: this auto-inserts two spaces.
(insert " ")
))

...我想在 ac-menu-map org-mode only< 中禁用此键绑定(bind)/strong>.

我尝试过以下方法:

;; Avoid always selecting unwanted first candidate with auto-complete 
;; when writing in org-mode.
(add-hook 'org-mode-hook
(lambda ()
;; (define-key ac-menu-map (kbd "SPC") nil)
;; (define-key ac-menu-map (kbd "SPC") 'self-insert-command)
;; (setq-local ac-menu-map (delq (kbd "SPC") ac-menu-map))
))

不幸的是,这不会在本地取消设置键绑定(bind)(即仅在org-mode中)。相反,它会从 ac-menu-map 各处删除按键绑定(bind)。

最佳答案

解决问题的另一种方法是检查 ac-complete-with-space 模式。如果org-mode,则调用self-insert-command,否则遵循您当前的逻辑。

关于emacs - 如何在本地模式中取消设置 map 中的键绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22834506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com