bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'


From: Eli Zaretskii
Subject: bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
Date: Thu, 21 Mar 2024 14:36:10 +0200

> From: tpeplt <tpeplt@gmail.com>
> Date: Mon, 18 Mar 2024 17:14:16 -0400
> 
> Recipe for reproducing this problem:
> 
> 1. Start Emacs at a shell prompt using "emacs -Q".
> 
> 2. Evaluate the following expressions in the *scratch* buffer.
> 
> The following keys evaluate as valid (as expected):
> 
> (key-valid-p "TAB")
> (key-valid-p "<TAB>")
> (key-valid-p "<tab>")
> 
> The following key evaluates as invalid (as expected):
> 
> (key-valid-p "tab")
> 
> 3. So, the following expressions should evaluate to
> ‘indent-for-tab-command’:
> 
> (keymap-global-set "<tab>" 'indent-for-tab-command)
> (keymap-global-set "TAB" 'indent-for-tab-command)
> (keymap-global-set "<TAB>" 'indent-for-tab-command)
> 
> The first two expressions evaluate as expected, but when the third
> expression is evaluated, then the following message is reported:
> 
> keymap-global-set: To bind the key TAB, use [?\t], not [TAB]
> 
> Because (key-valid-p "<TAB>") evaluates to t, that error message appears
> to be invalid.
> 
> 4. Also, the following expressions all evaluate to nil:
> 
> (key-valid-p "[?\t]")
> (key-valid-p "[?\\t]")
> 
> (key-valid-p "?\t")
> (key-valid-p "?\\t")
> 
> (key-valid-p "<?\t>")
> (key-valid-p "<?\\t>")
> 
> So the error message appears to direct a user to change the key string
> to an invalid key.

Stefan, is the below the right fix for this?

If not, why does key-parse omit TAB from the list of specially-handled
keys?

diff --git a/lisp/keymap.el b/lisp/keymap.el
index d2544e3..b2b475c 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -260,7 +260,7 @@ key-parse
                         (setq word (concat (match-string 1 word)
                                            (match-string 3 word)))
                         (not (string-match
-                              "\\<\\(NUL\\|RET\\|LFD\\|ESC\\|SPC\\|DEL\\)$"
+                              
"\\<\\(NUL\\|RET\\|LFD\\|TAB\\|ESC\\|SPC\\|DEL\\)$"
                               word))))
                  (setq key (list (intern word))))
                 ((or (equal word "REM") (string-match "^;;" word))





reply via email to

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