【问题标题】:Setting shortcuts keys in specific modes in Emacs (e.g. ido)在 Emacs 中以特定模式设置快捷键(例如 ido)
【发布时间】:2011-07-07 21:44:03
【问题描述】:

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

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

2) 我想保护我的 C-;,但只要 flyspell-mode 运行,它就会超过 C-;。我的定义在 .emacs 中为:

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

但显然 flyspell 覆盖了这个......(尽管即使那样,如果我查看帮助 M-h k C-; 它确实说mark-paragraph

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

非常感谢!

【问题讨论】:

  • @Trey Jackson:谢谢你的标记 - 现在我知道它是如何完成的了 :)

标签: emacs keyboard-shortcuts flyspell ido


【解决方案1】:

Flyspell 为C-; 绑定提供了自定义,因此您可以M-x customize RET flyspell-auto-correct-binding 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 钩子专门用于 minibuffer,但不清楚为什么需要它:ido-minibuffer-setup-hook

【讨论】:

  • 谢谢!有用!!我实际上确实查看了 ido.el ......但错过了这部分。 flyspell现在也可以了。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-09-04
  • 2011-07-26
  • 2021-07-16
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多