define-key DEF的位置放cons有什么作用?

define-key的文档里说:

(define-key KEYMAP KEY DEF)

DEF is anything that can be a key’s definition:

a cons (STRING . DEFN), meaning that DEFN is the definition (DEFN should be a valid definition in its own right),

那个STRING是干啥用的?有人知道吗?

https://whispering-beach-14031.herokuapp.com/define-key

推測確认是用在图形界面菜單的文本上,因為 Emacs 的图形菜單也是个 keymap。

https://whispering-beach-14031.herokuapp.com/make-sparse-keymap

The optional arg STRING supplies a menu name for the keymap in case you use it as a menu with ‘x-popup-menu’.

(type item-name . binding)

This specifies a binding which is also a simple menu item that displays as item-name in the menu. See Simple Menu Items.

3 个赞

的确是菜单上的文本,(info “(elisp) Menu Bar”) 中也有个可以运行的例子。