Emacs 将elisp事件字符串/向量转换为事件对象
在Elisp中,我需要使用(事件修改器事件)来确定最后一个事件是否涉及任何按下的修改器键。我使用read key sequence/read key sequence vector来捕获事件。前者返回字符串,而后者返回向量。两者似乎都不是有效的事件类型参数。如何将键序列字符串或向量转换为此类事件对象?谢谢。函数Emacs 将elisp事件字符串/向量转换为事件对象,emacs,elisp,Emacs,Elisp,在Elisp中,我需要使用(事件修改器事件)来确定最后一个事件是否涉及任何按下的修改器键。我使用read key sequence/read key sequence vector来捕获事件。前者返回字符串,而后者返回向量。两者似乎都不是有效的事件类型参数。如何将键序列字符串或向量转换为此类事件对象?谢谢。函数事件修饰符需要单个事件。键序列通常不是单个事件。有关分析按键序列中事件的示例,请参见帮助.el中定义描述按键的代码。例如,此位: ;; If KEY is a down-event
事件修饰符
需要单个事件。键序列通常不是单个事件。有关分析按键序列中事件的示例,请参见帮助.el
中定义描述按键的代码。例如,此位:
;; If KEY is a down-event, read and include the
;; corresponding up-event. Note that there are also
;; down-events on scroll bars and mode lines: the actual
;; event then is in the second element of the vector.
(and (vectorp key)
(let ((last-idx (1- (length key))))
(and (eventp (aref key last-idx))
(memq 'down (event-modifiers (aref key last-idx)))))
(or (and (eventp (aref key 0))
(memq 'down (event-modifiers (aref key 0)))
;; However, for the C-down-mouse-2 popup
;; menu, there is no subsequent up-event. In
;; this case, the up-event is the next
;; element in the supplied vector.
(= (length key) 1))
(and (> (length key) 1)
(eventp (aref key 1))
(memq 'down (event-modifiers (aref key 1)))))
(read-event))
函数事件修饰符
需要单个事件。键序列通常不是单个事件。有关分析按键序列中事件的示例,请参见帮助.el
中定义描述按键的代码。例如,此位:
;; If KEY is a down-event, read and include the
;; corresponding up-event. Note that there are also
;; down-events on scroll bars and mode lines: the actual
;; event then is in the second element of the vector.
(and (vectorp key)
(let ((last-idx (1- (length key))))
(and (eventp (aref key last-idx))
(memq 'down (event-modifiers (aref key last-idx)))))
(or (and (eventp (aref key 0))
(memq 'down (event-modifiers (aref key 0)))
;; However, for the C-down-mouse-2 popup
;; menu, there is no subsequent up-event. In
;; this case, the up-event is the next
;; element in the supplied vector.
(= (length key) 1))
(and (> (length key) 1)
(eventp (aref key 1))
(memq 'down (event-modifiers (aref key 1)))))
(read-event))
您在问题中给出了答案:/…if last event…/,因此您希望使用由read key sequence vector
返回的事件序列的最后一个元素。例如,(aref键(1-(长度键))
您在问题中给出了答案:/…如果最后一个事件…/,那么您希望使用读取键序列向量返回的事件序列的最后一个元素。例如,(aref键(1-(长度键))
如果您特别想读取单个事件,请使用读取事件
如果您特别想读取单个事件,请使用读取事件