Subject: bug#61185: 29.0.60; key-parse is not as strict as the other keymap APIs

From: Daniel Mendler <[email-masked]>
Date: Mon, 30 Jan 2023 22:01:56 +0100

The function `key-parse' is publicly exposed as part of the keymap.el
API. As such it would be good if it were as strict as the rest of the
API to improve consistency. Currently it accepts strings which are
invalid according to `key-valid-p'.

(key-valid-p "bug") ;; nil
(key-parse "bug")   ;; [98 117 103]

We can move the `key-valid-p' check to `key-parse'. This would alleviate
the need for many additional `key-valid-p' checks across keymap.el. Then
the `keymap--check' helper can even be removed.

There is the small complication that `kbd' has been reimplemented based
on `key-parse' which prevents `key-parse' from being more strict. One
can either introduce an internal `key--parse-lax' function which is then
used by `kbd' and `key-parse'.