Subject: bug#58799: Make winner key sequences repeatable in repeat-mode

From: Robert Pluim <[email-masked]>
Date: Thu, 27 Oct 2022 15:38:17 +0200

>>>>> On Thu, 27 Oct 2022 05:31:21 -0700, Stefan Kangas <[email-masked]> said:

    Stefan> Robert Pluim <[email-masked]> writes:
    >> (defvar-keymap winner-repeat-map
    >> :doc "Keymap to repeat winner key sequences.  Used in `repeat-mode'."
    >> <left> #'winner-undo
    >> <right> #'winner-redo)
    >> 
    >> (but you can stick them in a .el file)

    Stefan> Hmm, right.  I think that's a bug though, because when loading such a
    Stefan> .elc file I get:

    Stefan> keymap--check: [left] is not a valid key definition; see ‘key-valid-p’

    Stefan> So we should probably make sure that the `defvar-keymap' macro errors
    Stefan> out.

Thatʼs easy enough (putting it in `define-keymap' would bring out the
backwards-compatibility police, I think). Probably needs an update to
the `defvar-keymap' docstring as well.

Robert
-- 

diff --git a/lisp/keymap.el b/lisp/keymap.el
index 107565590c..73a9e657fe 100644
--- a/lisp/keymap.el
+++ b/lisp/keymap.el
@@ -581,6 +581,10 @@ defvar-keymap
         (setq key (pop defs))
         (pop defs)
         (when (not (eq key :menu))
+          (when (not (key-valid-p key))
+            (error
+             "Invalid key '%s' in keymap '%s' (see `key-valid-p')"
+             key variable-name))
           (if (member key seen-keys)
               (error "Duplicate definition for key '%s' in keymap '%s'"
                      key variable-name)