【发布时间】:2013-11-30 07:43:51
【问题描述】:
是否可以让<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))))
【问题讨论】: