emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 b63a9eda01c: Fix "C-h k" and "C-h c" with Paste from Kill Menu


From: Eli Zaretskii
Subject: emacs-29 b63a9eda01c: Fix "C-h k" and "C-h c" with Paste from Kill Menu
Date: Sat, 8 Apr 2023 08:37:04 -0400 (EDT)

branch: emacs-29
commit b63a9eda01c692d1c6dae8ef6563678f8ddd7faf
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix "C-h k" and "C-h c" with Paste from Kill Menu
    
    * lisp/subr.el (event-basic-type, event-modifiers): Return nil if
    EVENT is a string.  (Bug#62626)
---
 lisp/subr.el | 74 +++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 36 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 2e31929e548..46dcd97d829 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]