emacs 中什么是好的自定义键绑定?

2023-12-24

Emacs 似乎已经将所有可能的键盘组合随机分布在它的命令中。 :p

如果我要定义新的键盘快捷键,我应该将它们放在哪里?我应该使用哪些前缀?

例如:我想定义以下功能的快捷方式:

  • 缩进缓冲区(C-c i,在我得到答案后)
  • 注释或取消注释区域 (C-c C)
  • rdebug(Ruby 调试器)(C-c R)
  • rsense-complete(ruby 自动完成)(C-c e)

你会把这些放在哪里?为什么?


Emacs 实际上有一个非常明确的绑定模式,这个答案 https://stackoverflow.com/questions/2677300/learning-emacs-useful-mnemonics/2679400#2679400显示一些。

As far as where you should define keys, if you take a look at the documentation for conventions http://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html, you'll see that C-c a (where a is any lower or upper case character) is reserved for users.

另外,如果您定义的键实际上只在特定模式下有意义,那么您应该在该键映射中定义它。

For example, M-/ is bound to dabbrev-expand, which is a handy way of autocompleting the word you're typing. It might very well make sense to use rsense-complete instead, but only when you're in ruby. In which case, you can do this:

(add-hook 'ruby-mode-hook
     (lambda () (define-key ruby-mode-map (kbd "M-/") 'rsense-complete)))

That will override the binding for M-/ only when you're in ruby-mode, and leave it unchanged (or available) for the rest of the modes.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

emacs 中什么是好的自定义键绑定? 的相关文章

随机推荐