]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix "C-h k" and "C-h c" with Paste from Kill Menu
authorEli Zaretskii <eliz@gnu.org>
Sat, 8 Apr 2023 12:36:44 +0000 (15:36 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 8 Apr 2023 12:36:44 +0000 (15:36 +0300)
* lisp/subr.el (event-basic-type, event-modifiers): Return nil if
EVENT is a string.  (Bug#62626)

lisp/subr.el

index 2e31929e548e31c432d8dea0cd26869b348af4db..46dcd97d8291e4a80c1f5fb39d5f68984c3c3290 100644 (file)
@@ -1520,31 +1520,32 @@ EVENT may be an event or an event type.  If EVENT is a symbol
 that has never been used in an event that has been read as input
 in the current Emacs session, then this function may fail to include
 the `click' modifier."
-  (let ((type event))
-    (if (listp type)
-       (setq type (car type)))
-    (if (symbolp type)
-        ;; Don't read event-symbol-elements directly since we're not
-        ;; sure the symbol has already been parsed.
-       (cdr (internal-event-symbol-parse-modifiers type))
-      (let ((list nil)
-           (char (logand type (lognot (logior ?\M-\0 ?\C-\0 ?\S-\0
-                                              ?\H-\0 ?\s-\0 ?\A-\0)))))
-       (if (not (zerop (logand type ?\M-\0)))
-           (push 'meta list))
-       (if (or (not (zerop (logand type ?\C-\0)))
-               (< char 32))
-           (push 'control list))
-       (if (or (not (zerop (logand type ?\S-\0)))
-               (/= char (downcase char)))
-           (push 'shift list))
-       (or (zerop (logand type ?\H-\0))
-           (push 'hyper list))
-       (or (zerop (logand type ?\s-\0))
-           (push 'super list))
-       (or (zerop (logand type ?\A-\0))
-           (push 'alt list))
-       list))))
+  (unless (stringp event)
+    (let ((type event))
+      (if (listp type)
+         (setq type (car type)))
+      (if (symbolp type)
+          ;; Don't read event-symbol-elements directly since we're not
+          ;; sure the symbol has already been parsed.
+         (cdr (internal-event-symbol-parse-modifiers type))
+        (let ((list nil)
+             (char (logand type (lognot (logior ?\M-\0 ?\C-\0 ?\S-\0
+                                                ?\H-\0 ?\s-\0 ?\A-\0)))))
+         (if (not (zerop (logand type ?\M-\0)))
+             (push 'meta list))
+         (if (or (not (zerop (logand type ?\C-\0)))
+                 (< char 32))
+             (push 'control list))
+         (if (or (not (zerop (logand type ?\S-\0)))
+                 (/= char (downcase char)))
+             (push 'shift list))
+         (or (zerop (logand type ?\H-\0))
+             (push 'hyper list))
+         (or (zerop (logand type ?\s-\0))
+             (push 'super list))
+         (or (zerop (logand type ?\A-\0))
+             (push 'alt list))
+         list)))))
 
 (defun event-basic-type (event)
   "Return the basic type of the given event (all modifiers removed).
@@ -1552,17 +1553,18 @@ The value is a printing character (not upper case) or a symbol.
 EVENT may be an event or an event type.  If EVENT is a symbol
 that has never been used in an event that has been read as input
 in the current Emacs session, then this function may return nil."
-  (if (consp event)
-      (setq event (car event)))
-  (if (symbolp event)
-      (car (get event 'event-symbol-elements))
-    (let* ((base (logand event (1- ?\A-\0)))
-          (uncontrolled (if (< base 32) (logior base 64) base)))
-      ;; There are some numbers that are invalid characters and
-      ;; cause `downcase' to get an error.
-      (condition-case ()
-         (downcase uncontrolled)
-       (error uncontrolled)))))
+  (unless (stringp event)
+    (if (consp event)
+        (setq event (car event)))
+    (if (symbolp event)
+        (car (get event 'event-symbol-elements))
+      (let* ((base (logand event (1- ?\A-\0)))
+            (uncontrolled (if (< base 32) (logior base 64) base)))
+        ;; There are some numbers that are invalid characters and
+        ;; cause `downcase' to get an error.
+        (condition-case ()
+           (downcase uncontrolled)
+         (error uncontrolled))))))
 
 (defsubst mouse-movement-p (object)
   "Return non-nil if OBJECT is a mouse movement event."