all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 73764@debbugs.gnu.org, eduardoochs@gmail.com
Subject: bug#73764: format-kbd-macro returns a key name that keymap-lookup doesn't recognize
Date: Sat, 12 Oct 2024 17:36:05 +0300	[thread overview]
Message-ID: <8634l1wfqi.fsf@gnu.org> (raw)
In-Reply-To: <jwviktxihdb.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Sat, 12 Oct 2024 09:33:59 -0400)

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Eduardo Ochs <eduardoochs@gmail.com>,  73764@debbugs.gnu.org
> Date: Sat, 12 Oct 2024 09:33:59 -0400
> 
> >>   (keymap-lookup global-map "M-C-h")
> >>     ;;-> "M-C-h" is not a valid key definition; see `key-valid-p'
> [...]
> > Should we fix key-valid-p to be more lenient?
> 
> AFAIK the strictness was a conscious choice, so maybe we should simply
> improve the error message to say something like "M-C-h uses an invalid
> modifier ordering, maybe you meant C-M-h".

The general problem is much wider, so it is not easy to intuit "what
you meant".  E.g., what do you say if the key is "S-s-M-H-A-C-b"?  Do
you want to have a function that reorders the modifiers in canonical
order?  And if we have such a function, why not reorder silently and
accept the key, like we do with the order of BEG..END in functions
that accept the region?

> >> if we run this
> >>
> >>   (format-kbd-macro (read-key-sequence-vector "Type C-M-h:"))
> >>
> >> we get "M-C-h".
> 
> I guess we also need to make sure `format-kbd-macro` generates
> something that `key-valid-p` accepts.

AFAICS, that's impossible without completely rewriting its code.  It
proceeds from left to right (i.e. from MSB to LSB).

> > Or maybe just remove the call to keymap--check from keymap-lookup?
> 
> IIRC we wanted to use `keymap--check` on all input coming from the user,
> so I guess the question is whether the second arg of `keymap-lookup` is
> expected to be an immediate constant.

But keymap-look up is not an interactive function.

> That function is still young, so it's hard to tell how it'll turn up,
> but my `grep` says that indeed many (most) calls take a literal string
> as argument, so `keymap--check` seems appropriate.

If we remove the call to keymap--check, won't the other APIs signal an
error instead?  If they will, why do we need to protect them?





  reply	other threads:[~2024-10-12 14:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12  4:46 bug#73764: format-kbd-macro returns a key name that keymap-lookup doesn't recognize Eduardo Ochs
2024-10-12  9:18 ` Eli Zaretskii
2024-10-12 13:33   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 14:36     ` Eli Zaretskii [this message]
2024-10-12 14:51       ` Andreas Schwab
2024-10-12 15:18         ` Eli Zaretskii
2024-10-14 15:06           ` Robert Pluim
2024-10-14 15:54             ` Eli Zaretskii
2024-10-14 16:25               ` Eli Zaretskii
2024-10-14 21:48                 ` Stefan Kangas

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=8634l1wfqi.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=73764@debbugs.gnu.org \
    --cc=eduardoochs@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /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.