unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
@ 2024-03-18 21:14 tpeplt
  2024-03-21 12:36 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: tpeplt @ 2024-03-18 21:14 UTC (permalink / raw)
  To: 69893

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.

--











^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
  2024-03-18 21:14 bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set' tpeplt
@ 2024-03-21 12:36 ` Eli Zaretskii
  2024-03-21 19:46   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2024-03-21 12:36 UTC (permalink / raw)
  To: tpeplt, Stefan Monnier; +Cc: 69893

> 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))





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
  2024-03-21 12:36 ` Eli Zaretskii
@ 2024-03-21 19:46   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-03-21 20:13     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-21 19:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 69893, tpeplt

> Stefan, is the below the right fix for this?

Looks correct to me.
That code dates back to

    commit 629d4dcd2a184da6a0b246d31f152a84327db51a
    Author: Richard M. Stallman <rms@gnu.org>
    Date:   Tue Sep 21 03:44:04 1993 +0000
    
        Total rewrite by Gillespie.

and I suspect it was just an oversight.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
  2024-03-21 19:46   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-03-21 20:13     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-03-21 20:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 69893-done, tpeplt

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: tpeplt <tpeplt@gmail.com>,  69893@debbugs.gnu.org
> Date: Thu, 21 Mar 2024 15:46:08 -0400
> 
> > Stefan, is the below the right fix for this?
> 
> Looks correct to me.
> That code dates back to
> 
>     commit 629d4dcd2a184da6a0b246d31f152a84327db51a
>     Author: Richard M. Stallman <rms@gnu.org>
>     Date:   Tue Sep 21 03:44:04 1993 +0000
>     
>         Total rewrite by Gillespie.
> 
> and I suspect it was just an oversight.

Thanks, installed on the emacs-29 branch, and closing the bug.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-21 20:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18 21:14 bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set' tpeplt
2024-03-21 12:36 ` Eli Zaretskii
2024-03-21 19:46   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-21 20:13     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).