emacs-diffs
[Top][All Lists]
Advanced

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

master e321f87aa7: Avoid "control-control-KEY" (bug#55738)


From: Mattias Engdegård
Subject: master e321f87aa7: Avoid "control-control-KEY" (bug#55738)
Date: Sat, 18 Jun 2022 05:24:54 -0400 (EDT)

branch: master
commit e321f87aa76c959faed784851b65ab7ada3fd129
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Avoid "control-control-KEY" (bug#55738)
    
    Constructs such as ?\C-^@ or ?\C-\C-m literally apply a Control
    modifier twice which doesn't make sense at all.  What is really meant
    is a C0 base character with the Control modifier bit set.
    This change is only stylistic in nature.
    
    * lisp/edmacro.el (edmacro-format-keys):
    * lisp/keymap.el (key-parse):
    * lisp/subr.el (event-modifiers, event-basic-type):
    * test/lisp/subr-tests.el (subr-test-kbd):
    Use \0 and \r instead of ^@ and \C-m to represent NUL and RET
    when combined with other modifiers.
---
 lisp/edmacro.el         |  4 ++--
 lisp/keymap.el          | 14 +++++++-------
 lisp/subr.el            | 18 +++++++++---------
 test/lisp/subr-tests.el |  2 +-
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index fe1fc086bc..04adabd06b 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -532,8 +532,8 @@ doubt, use whitespace."
                               ((integerp ch)
                                (concat
                                 (cl-loop for pf across "ACHMsS"
-                                         for bit in '(?\A-\^@ ?\C-\^@ ?\H-\^@
-                                                              ?\M-\^@ ?\s-\^@ 
?\S-\^@)
+                                         for bit in '( ?\A-\0 ?\C-\0 ?\H-\0
+                                                       ?\M-\0 ?\s-\0 ?\S-\0)
                                          when (/= (logand ch bit) 0)
                                          concat (format "%c-" pf))
                                 (let ((ch2 (logand ch (1- (ash 1 18)))))
diff --git a/lisp/keymap.el b/lisp/keymap.el
index 71454eba5e..3a22610499 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -241,13 +241,13 @@ See `kbd' for a descripion of KEYS."
                      (setq bits (+ bits
                                    (cdr
                                     (assq (aref word 0)
-                                          '((?A . ?\A-\^@) (?C . ?\C-\^@)
-                                            (?H . ?\H-\^@) (?M . ?\M-\^@)
-                                            (?s . ?\s-\^@) (?S . ?\S-\^@))))))
+                                          '((?A . ?\A-\0) (?C . ?\C-\0)
+                                            (?H . ?\H-\0) (?M . ?\M-\0)
+                                            (?s . ?\s-\0) (?S . ?\S-\0))))))
                      (setq prefix (+ prefix 2))
                      (setq word (substring word 2)))
                    (when (string-match "^\\^.$" word)
-                     (setq bits (+ bits ?\C-\^@))
+                     (setq bits (+ bits ?\C-\0))
                      (setq prefix (1+ prefix))
                      (setq word (substring word 1)))
                    (let ((found (assoc word '(("NUL" . "\0") ("RET" . "\r")
@@ -262,19 +262,19 @@ See `kbd' for a descripion of KEYS."
                        (setq word (vector n))))
                    (cond ((= bits 0)
                           (setq key word))
-                         ((and (= bits ?\M-\^@) (stringp word)
+                         ((and (= bits ?\M-\0) (stringp word)
                                (string-match "^-?[0-9]+$" word))
                           (setq key (mapcar (lambda (x) (+ x bits))
                                             (append word nil))))
                          ((/= (length word) 1)
                           (error "%s must prefix a single character, not %s"
                                  (substring orig-word 0 prefix) word))
-                         ((and (/= (logand bits ?\C-\^@) 0) (stringp word)
+                         ((and (/= (logand bits ?\C-\0) 0) (stringp word)
                                ;; We used to accept . and ? here,
                                ;; but . is simply wrong,
                                ;; and C-? is not used (we use DEL instead).
                                (string-match "[@-_a-z]" word))
-                          (setq key (list (+ bits (- ?\C-\^@)
+                          (setq key (list (+ bits (- ?\C-\0)
                                              (logand (aref word 0) 31)))))
                          (t
                           (setq key (list (+ bits (aref word 0)))))))))
diff --git a/lisp/subr.el b/lisp/subr.el
index c1c9759b03..d14efccd82 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1542,21 +1542,21 @@ the `click' modifier."
         ;; sure the symbol has already been parsed.
        (cdr (internal-event-symbol-parse-modifiers type))
       (let ((list nil)
-           (char (logand type (lognot (logior ?\M-\^@ ?\C-\^@ ?\S-\^@
-                                              ?\H-\^@ ?\s-\^@ ?\A-\^@)))))
-       (if (not (zerop (logand type ?\M-\^@)))
+           (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-\^@)))
+       (if (or (not (zerop (logand type ?\C-\0)))
                (< char 32))
            (push 'control list))
-       (if (or (not (zerop (logand type ?\S-\^@)))
+       (if (or (not (zerop (logand type ?\S-\0)))
                (/= char (downcase char)))
            (push 'shift list))
-       (or (zerop (logand type ?\H-\^@))
+       (or (zerop (logand type ?\H-\0))
            (push 'hyper list))
-       (or (zerop (logand type ?\s-\^@))
+       (or (zerop (logand type ?\s-\0))
            (push 'super list))
-       (or (zerop (logand type ?\A-\^@))
+       (or (zerop (logand type ?\A-\0))
            (push 'alt list))
        list))))
 
@@ -1570,7 +1570,7 @@ in the current Emacs session, then this function may 
return nil."
       (setq event (car event)))
   (if (symbolp event)
       (car (get event 'event-symbol-elements))
-    (let* ((base (logand event (1- ?\A-\^@)))
+    (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.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index a25eb363b0..45dd2d7160 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -112,7 +112,7 @@
   (should (equal (kbd "C-x C-f") "\C-x\C-f"))
   (should (equal (kbd "C-M-<down>") [C-M-down]))
   (should (equal (kbd "<C-M-down>") [C-M-down]))
-  (should (equal (kbd "C-RET") [?\C-\C-m]))
+  (should (equal (kbd "C-RET") [?\C-\r]))
   (should (equal (kbd "C-SPC") [?\C- ]))
   (should (equal (kbd "C-TAB") [?\C-\t]))
   (should (equal (kbd "C-<down>") [C-down]))



reply via email to

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