当某些条件存在时,是否有可能<escape>
激活函数,但当不满足这些条件时,它的行为类似于修饰键?
(define-key lawlist-mode-map (kbd "<escape>") (lambda () (interactive)
(cond
((ABC . . .)
(message "You have satisfied condition ABC."))
((DEF . . .)
(message "You have satisfied condition DEF."))
(t (The <escape> key shall behave like a modifier key: ESC- )) )))
编辑:基于Stefan提供的 awesome 解决方案/答案,以下是如何在多个条件下使用他的代码的说明(例如,如果是ABC,则执行X;如果是DEF,然后做Y)。我将此示例包含在像我这样的慢学习者中 - 也就是说,花了一些时间来了解如何正确应用代码。
(global-set-key (kbd "<escape>") `(menu-item ""
,(lambda () (interactive)
(cond
((Set forth condition ABC.)
(message "You have satisfied condition ABC."))
((Set forth condition DEF.)
(message "You have satisfied condition DEF."))))
:filter ,(lambda (binding)
(if (or (Set forth condition ABC.)
(Set forth condition DEF.))
binding))))
答案 0 :(得分:2)
您可以执行以下操作:
(define-key lawlist-mode-map [?\e]
`(menu-item "" ,(lambda () (interactive) (message "You have satisfied condition ABC."))
:filter ,(lambda (binding) (if (ABC ...) binding))))