Subject: Re: bug#73764: format-kbd-macro returns a key name that keymap-lookup doesn't recognize

From: Eli Zaretskii <[email-masked]>
Date: Sat, 12 Oct 2024 12:18:37 +0300

> From: Eduardo Ochs <[email-masked]>
> Date: Sat, 12 Oct 2024 01:46:26 -0300
> 
> if we run this
> 
>   (format-kbd-macro (read-key-sequence-vector "Type C-M-h:"))
> 
> we get "M-C-h". But try:
> 
>   (keymap-lookup global-map "M-C-h")
>     ;;-> "M-C-h" is not a valid key definition; see `key-valid-p'
> 
>   (keymap-lookup global-map "C-M-h")
>     ;;-> mark-defun

This is because key-valid-p is too restrictive: it only accepts
modifiers in the canonical order A-C-H-M-S-s.  But key-parse, which is
called by keymap-lookup, accepts and correctly processes the modifiers
in any order:

  (key-parse "M-C-h")
   => [134217736]

Should we fix key-valid-p to be more lenient?  Or maybe just remove
the call to keymap--check from keymap-look up?

Stefan, WDYT?