diff options
| author | Richard M. Stallman | 1993-03-07 07:35:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-03-07 07:35:57 +0000 |
| commit | 53e5a4e8a4f97bcd9907f6cebb0ba2468b9e5ba8 (patch) | |
| tree | e43dbed75b36c97222981463760f66960324d76f | |
| parent | ecc71b7f7d22cc90df74678375f54645c007f96b (diff) | |
| download | emacs-53e5a4e8a4f97bcd9907f6cebb0ba2468b9e5ba8.tar.gz emacs-53e5a4e8a4f97bcd9907f6cebb0ba2468b9e5ba8.zip | |
(event-modifiers): New function.
(eventp): New function.
| -rw-r--r-- | lisp/subr.el | 36 |
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. | ||
| 222 | The elements of the list may include `meta', `control', | ||
| 223 | `shift', `hyper', `super', `alt'. | ||
| 224 | See 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"))) |