Keystrokes are associated with commands via key bindings.
you can access those command don't have bindings by typing M-x command-name Enter.
key-map is a collection of key bindings.Global-mapis the most basic default key bindings in Emacs.Local-map is specific to a single buffer.Local key-maps are used to implement commands in modes
Emacs first looks it up in the current buffer's local-map (if any). If it doesn't find an entry there, it looks in global-map. If an entry for the key is found, its associated command is run.
键的绑定
You can create your own key bindings by adding entries in key-maps (or overriding existing ones). Three functions are available for doing this: define-key, global-set-key, and local-set-key. Their forms are:
(define-key keymap "keystroke" 'command-name)
(global-set-key "keystroke" 'command-name) <=> (define-key global-map "keystroke" 'command-name)
(local-set-key "keystroke" 'command-name) <=> (define-key local-map "keystroke" 'command-name)
比如goto-line 命令用于跳转到某一行,当你进行调试的时候,会报出具体那一行出错,所以这个命令就是比较常用的。
(global-set-key "\C-xl" 'goto-line)
然后你可以通过C-x C-e 来执行光标所在的行,使他生效。
map的扩展
另外因为C-x / M- 这种等待后续输入的操作,同样具有自己的map,比如C-x 有Ctrl-x-map 所以下面的语法跟上面是等价的。
(define-key ctl-x-map "l" 'goto-line)
设置到特殊键
arrow,number keypad, Function keys. 分别为箭头,小键盘,F1系列功能键这个时候它不再是把keystrke放入双引号中,而是在一对方括号里面
(global-set-key [f5] 'goto-line) F5被赋予goto-line
(global-set-key [C-A-f5] 'goto-line) Ctrl+alt+f5被赋予goto-line
取消键绑定
(global-unset-key [f5])
(define-key ctl-x-map "l" nil)
http://ergoemacs.org/emacs/keyboard_shortcuts.html
http://ergoemacs.org/emacs/keyboard_shortcuts.html