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.