all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: Robert Pluim <rpluim@gmail.com>,
	59305@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#59305: 29.0.50; keymap-global-set handling of string bindings different from global-set-key
Date: Thu, 02 May 2024 09:13:41 -0400	[thread overview]
Message-ID: <jwvr0ekbcri.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CADwFkmmLXvGvdZvo5G=rVGaL71ZQMNc3NXrj7WXaATM0qksSMQ@mail.gmail.com> (Stefan Kangas's message of "Thu, 24 Nov 2022 16:14:05 -0800")

>> Whilst not strictly a regression, this behaviour is confusing and
>> unhelpful, and the solution is not easily found. I can think of two
>> solutions:
>>
>> 1. Change `kbd' to always return a vector even if the input is
>> ascii-only, which makes [4] work

`key-parse` always returns a vector.

>> 2. Change `keymap-set' to convert ascii-only strings to the format in
>> [5] or [6]. Probably just a call to `string-to-vector' is enough.
>
> I feel like the second alternative goes against the design of
> `keymap-global-set', where the idea explicitly was to only support a KEY
> argument that is `key-valid-p'.

The problem with 2 is that it requires a heuristic that tries to guess
which kind of string it is (either the good "new" kbd-style or the old
bad event-sequence).  This *will* misfire sooner or later.

>> (string-to-vector "foo") will do. But that just highlights the problem
>> even more: if itʼs that simple, why canʼt `keymap-global-set' do that
>> internally instead of forcing users to jump through hoops?
> AFAIU, because otherwise we can't have error handling for common typos,
> such as:

It's worse than that: we cannot reliably know whether the user meant for
the string to be a kbd-style description of events or a "raw" sequence
of events.

E.g. should

    (keymap-global-set <foo> "C-a")

remap that <foo> sequence to [?\C-a] or to [?C ?- ?a]?

> Then perhaps we should just change the docstrings and manual to
> explain that binding a key to a string of characters should use
> `kmacro' (since `kbd' is not the right thing for ASCII-only entry)

I fully support this: I think we should phase out the
use of strings/vectors as commands.


        Stefan






  parent reply	other threads:[~2024-05-02 13:13 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
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 [this message]
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=jwvr0ekbcri.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59305@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rpluim@gmail.com \
    --cc=stefankangas@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 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.