mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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.
This commit is contained in:
parent
15238e2ed0
commit
e321f87aa7
4 changed files with 19 additions and 19 deletions
|
|
@ -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)))))
|
||||
|
|
|
|||
|
|
@ -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)))))))))
|
||||
|
|
|
|||
18
lisp/subr.el
18
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.
|
||||
|
|
|
|||
|
|
@ -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]))
|
||||
|
|
|
|||
Loading…
Reference in a new issue