unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: tpeplt <tpeplt@gmail.com>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 69893@debbugs.gnu.org
Subject: bug#69893: 29.2; Valid key "<TAB>" not accepted by `keymap-global-set'
Date: Thu, 21 Mar 2024 14:36:10 +0200	[thread overview]
Message-ID: <86wmpv224l.fsf@gnu.org> (raw)
In-Reply-To: <87plvr9r9z.fsf@gmail.com> (message from tpeplt on Mon, 18 Mar 2024 17:14:16 -0400)

> 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	other threads:[~2024-03-21 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wmpv224l.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=69893@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=tpeplt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).