aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/subr.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 27ddcf31095..5f30e0bd96c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -208,6 +208,42 @@ in KEYMAP as NEWDEF those chars which are defined as OLDDEF in OLDMAP."
208 c))) 208 c)))
209 (append key nil)))) 209 (append key nil))))
210 210
211(defsubst eventp (obj)
212 "True if the argument is an event object."
213 (or (integerp obj)
214 (and (symbolp obj)
215 (get obj 'event-symbol-elements))
216 (and (consp obj)
217 (symbolp (car obj))
218 (get (car obj) 'event-symbol-elements))))
219
220(defun event-modifiers (event)
221 "Returns a list of symbols representing the modifier keys in event EVENT.
222The elements of the list may include `meta', `control',
223`shift', `hyper', `super', `alt'.
224See also the function `event-modifier-bits'."
225 (let ((type event))
226 (if (listp type)
227 (setq type (car type)))
228 (if (symbolp type)
229 (cdr (get type 'event-symbol-elements))
230 (let ((list nil))
231 (or (zerop (logand type (lsh 1 23)))
232 (setq list (cons 'meta list)))
233 (or (and (zerop (logand type (lsh 1 22)))
234 (>= (logand type 127) 32))
235 (setq list (cons 'control list)))
236 (or (and (zerop (logand type (lsh 1 21)))
237 (= (logand type 255) (downcase (logand type 255))))
238 (setq list (cons 'shift list)))
239 (or (zerop (logand type (lsh 1 20)))
240 (setq list (cons 'hyper list)))
241 (or (zerop (logand type (lsh 1 19)))
242 (setq list (cons 'super list)))
243 (or (zerop (logand type (lsh 1 18)))
244 (setq list (cons 'alt list)))
245 list))))
246
211(defmacro save-match-data (&rest body) 247(defmacro save-match-data (&rest body)
212 "Execute the BODY forms, restoring the global value of the match data." 248 "Execute the BODY forms, restoring the global value of the match data."
213 (let ((original (make-symbol "match-data"))) 249 (let ((original (make-symbol "match-data")))