Emacs中密钥映射的两种方法
我发现在emacs中有两种设置键的方法:golbal set key和define key。 它们是一样的吗?或者这两种方法之间有什么利弊Emacs中密钥映射的两种方法,emacs,Emacs,我发现在emacs中有两种设置键的方法:golbal set key和define key。 它们是一样的吗?或者这两种方法之间有什么利弊 (global-set-key (kbd "C-c C-f") 'my-find-file) (define-key global-map "\C-ck" 'hello) 实际上没有区别,如果您查看global set key的定义,您将看到: (define-key (current-global-map) key command) (当前全局映射
(global-set-key (kbd "C-c C-f") 'my-find-file)
(define-key global-map
"\C-ck" 'hello)
实际上没有区别,如果您查看
global set key
的定义,您将看到:
(define-key (current-global-map) key command)
(当前全局映射)
可能会返回一个与全局键映射不同但不常见的键映射
现在,由于define key
接受keymap的参数,因此它显然比简单的global set key
更灵活。有关键映射的详细信息,请查看。区别在于(全局设置键)
或(本地设置键)
为您找到全局/本地映射(在调用(定义键)
之前)
编辑您可以对(全局设置键)
对于(定义键)
(global-set-key key command)
Give key a global binding as command.
command is the command definition to use; usually it is
a symbol naming an interactively-callable function.
key is a key sequence; noninteractively, it is a string or vector
of characters or event types, and non-ASCII characters with codes
above 127 (such as ISO Latin-1) can be included if you use a vector.
(define-key keymap key def)
In keymap, define key sequence key as def.
keymap is a keymap.
key is a string or a vector of symbols and characters meaning a
sequence of keystrokes and events. Non-ASCII characters with codes
above 127 (such as ISO Latin-1) can be included if you use a vector.
Using [t] for key creates a default definition, which applies to any
event type that has no other definition in this keymap.