问题描述
当某些条件存在时,是否可以有< escape>
激活功能,但是当这些条件不符合时,它们的行为就像修饰符键?
$($)$($)$($)$
((ABC。。)
(消息您已经满足条件ABC))
((DEF。)。
(消息您已满足条件DEF 。))
(t(< escape>键的行为就像一个修饰符键:ESC-)))))
编辑:根据Stefan提供的 awesome 解决方案/答案,以下是如何使用他的代码有多个条件(例如,如果ABC,然后做X;如果DEF,然后做Y)。我正在包括像我这样的慢学习者的例子 - 也就是说,花了我一些时间来了解如何正确地应用代码。
(全局设置键(kbd< escape>)`(menu-item
,(lambda()(interactive)
(cond
(消息你已经满足条件ABC))
((设定条件DEF。)
(消息你已经满足条件DEF)) )
:filter,(lambda(binding)
(if(或(设置条件ABC))
(设置条件DEF))
binding)))
您可以执行以下操作:
(define-key lawlist-mode-map [?\e]
`(menu-item,(lambda()互动)(消息你已经满足条件ABC))
:filter,(lambda(binding)(if(ABC ...)binding))))
Is it possible to have <escape>
activate functions when certain conditions exist, yet behave like a modifier key when those conditions are not met?
(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- )) )))
EDIT: Based upon the awesome solution / answer provide by Stefan, the following is an illustration of how to use his code with multiple conditions (e.g., if ABC, then do X; if DEF, then do Y). I am including this example for slow-learners like myself -- i.e., it took me some time to understand how to apply the code correctly.
(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))))
You can do something like:
(define-key lawlist-mode-map [?\e]
`(menu-item "" ,(lambda () (interactive) (message "You have satisfied condition ABC."))
:filter ,(lambda (binding) (if (ABC ...) binding))))
这篇关于如何使用< escape> (有条件地)作为修饰键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!