在Emacs中设置特定模式下的快捷键(例如ido)

发布于 2024-11-18 21:31:49 字数 537 浏览 3 评论 0原文

我认为有两个有些相关的问题:

1)在IDO中,我想将ido-restrict-to-matches更改为除C-SPCC-@<以外的其他内容/kbd>。不幸的是我不知道如何告诉 emacs 我想要一个不同的快捷方式(比如 C-0)。

2) 我想保护我的 C-;,但每当 Flyspell-mode 运行时,它就会取代 C-;。我的定义在 .emacs 中为:

(global-set-key (kbd "C-;") 'mark-paragraph)

但显然 Flyspell 会覆盖这个...(尽管如此,如果我查看帮助 Mh k C-; 它确实说 mark-paragraph)

有人可以告诉我如何在这些情况下绑定/取消绑定键吗?它必须在不修改 ido.el 和 Flyspell.el 并重新构建的情况下工作,对吧?

非常感谢!

I have two problems which are somewhat related I believe:

1) In IDO I'd like to change ido-restrict-to-matches to samething else than C-SPC or C-@. Unfortunately I do not know how to tell emacs that I want a different shortcut (say C-0).

2) I'd like to protect my C-; but whenever flyspell-mode is running it overtakes C-;. My definition is in .emacs as:

(global-set-key (kbd "C-;") 'mark-paragraph)

but apparently flyspell overwrites this... (although even then, if I look in the help M-h k C-; it does say mark-paragraph)

Could somebody please tell me how to bind/unbind keys in these conditions? It has to work without modifying ido.el and flyspell.el and re-building, right?

Thanks very much!

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

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

发布评论

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

评论(1

鹿! 2024-11-25 21:31:49

Flyspell 提供了对 C-; 绑定的自定义,因此您可以 Mx 自定义 RET Flyspell-auto- Correct-Bing RET 或将类似的内容放入您的 ~/.emacs

(setq flyspell-auto-correct-binding (kbd "C-~")) ; or a binding of your choice

至于 ido,你的问题有点令人困惑,因为它意味着有时你在迷你缓冲区之外使用 ido...

ido.el 中的文档包含以下建议:

;; To modify the keybindings, use the ido-setup-hook.  For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
;;
;;(defun ido-my-keys ()
;;  "Add my keybindings for ido."
;;  (define-key ido-completion-map " " 'ido-next-match)
;;  )

利用这些知识,您可以在您自己的“ido-my-keys”函数中更改键绑定:

(define-key ido-completion-map (kbd "C-SPC") nil)
(define-key ido-completion-map (kbd "C-@") nil)
(define-key ido-completion-map (kbd "C-0") 'ido-restrict-to-matches)

还有一个专门用于迷你缓冲区的附加 ido 挂钩,但不清楚为什么您需要它:ido-minibuffer-setup-钩子

Flyspell provides a customization for the C-; binding, so you can either M-x customize RET flyspell-auto-correct-binding RET or put something like this in your ~/.emacs:

(setq flyspell-auto-correct-binding (kbd "C-~")) ; or a binding of your choice

As for ido, your question is slightly confusing, because it implies there are times when you're using ido outside the minibuffer...

The documentation in ido.el contains the following advice:

;; To modify the keybindings, use the ido-setup-hook.  For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
;;
;;(defun ido-my-keys ()
;;  "Add my keybindings for ido."
;;  (define-key ido-completion-map " " 'ido-next-match)
;;  )

Using that knowledge, you can change the key bindings like this in your own "ido-my-keys" function:

(define-key ido-completion-map (kbd "C-SPC") nil)
(define-key ido-completion-map (kbd "C-@") nil)
(define-key ido-completion-map (kbd "C-0") 'ido-restrict-to-matches)

There's an additional ido hook specifically for the minibuffer, too, but it's not clear why you would need that: ido-minibuffer-setup-hook.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文