all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: 59305@debbugs.gnu.org
Subject: bug#59305: 29.0.50; keymap-global-set handling of string bindings different from global-set-key
Date: Tue, 22 Nov 2022 17:58:07 +0100	[thread overview]
Message-ID: <87h6yrexk0.fsf@gmail.com> (raw)
In-Reply-To: <87edu3cml8.fsf@gmail.com> (Robert Pluim's message of "Wed, 16 Nov 2022 09:47:31 +0100")

>>>>> On Wed, 16 Nov 2022 09:47:31 +0100, Robert Pluim <rpluim@gmail.com> said:

    Robert> 1. Change `kbd' to always return a vector even if the input is
    Robert> ascii-only, which makes [4] work

I tried that, and it seems to work, but I guess itʼs kind of
risky. Just what we need to see if people are testing the pre-test
properly 😸

    Robert> 2. Change `keymap-set' to convert ascii-only strings to the format in
    Robert> [5] or [6]. Probably just a call to `string-to-vector' is enough.

This is less invasive. Something like this:

diff --git a/lisp/keymap.el b/lisp/keymap.el
index eaeba96644..deb44844fb 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -61,7 +61,23 @@ keymap-set
   ;; If we're binding this key to another key, then parse that other
   ;; key, too.
   (when (stringp definition)
-    (keymap--check definition)
+    ;; For backwards compatibility, we want people to be able to say
+    ;; "hello" instead of forcing them to say "h e l l o", and to fix
+    ;; the common mistake of specifying a string with non-ascii
+    ;; characters, we convert to a vector instead.
+    (cond
+     ((let ((case-fold-search nil)) ;; no special chars or keywords
+             (not (string-match-p
+                   (rx (or " " "^" "<" ">" "-" "\\"
+                           "NUL" "RET" "TAB" "LFD"
+                           "ESC" "SPC" "DEL")))))
+      (setq definition (string-join (seq-split definition 1) " "))
+      (keymap--check definition))
+     ((string-match-p ;; non-ascii characters
+       "[[:nonascii:]]" definition)
+      (setq definition (string-to-vector definition)))
+     (t ;; kbd syntax
+      (keymap--check definition)))
     (setq definition (key-parse definition)))
   (define-key keymap (key-parse key) definition))


Robert
-- 





  reply	other threads:[~2022-11-22 16:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  8:47 bug#59305: 29.0.50; keymap-global-set handling of string bindings different from global-set-key Robert Pluim
2022-11-22 16:58 ` Robert Pluim [this message]
2022-11-25  0:14 ` Stefan Kangas
2022-11-25  8:01   ` Robert Pluim
2022-11-25  8:25     ` Stefan Kangas
2022-12-15  8:42       ` Robert Pluim
2024-04-26 14:34         ` Robert Pluim
2024-05-02  9:01           ` Eli Zaretskii
2024-05-02 13:13   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 10:03     ` Robert Pluim
2024-05-06 13:24       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 14:34         ` Robert Pluim
2024-05-06 15:20           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

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

  git send-email \
    --in-reply-to=87h6yrexk0.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=59305@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.