Subject: bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints"

From: JD Smith <[email-masked]>
Date: Sun, 28 Apr 2024 08:45:19 -0400

> On Apr 28, 2024, at 2:58 AM, Juri Linkov <[email-masked]> wrote
>> Of course a new wrapper macro could also be developed to ease this.
>> Do you anticipate any specific issues?
> 
> Here is what I recommend to do to simplify the definition of hints for users.
> 
> Like there can be a list of enter and exit commands in 'defvar-keymap':
> 
>  :repeat ‘(:enter (commands ...) :exit (commands ...))’
> 
> the same list could be used for hints:
> 
>  :repeat ‘(:enter (commands ...) :exit (commands ...) :hints ((command . hint) ...))’
> 
> This should be easier to document and to understand by users than
> a special syntax of cons for binding and the requirement to add :name.

Though it will require repetition and thus be subject to changed-here-but-not-there errors, this does look good and nicely groups the information under :repeat.  So this should work for all commands in the keymap:

> (defvar-keymap expreg-repeat-map
>    :doc "Repeat map for `expreg' actions."
>    :repeat '(:hints ((expreg-expand . "expand") (expreg-contract . "contract")))
>    "\\" 'expreg-expand
>    "|"  'expreg-contract)

If a hint is missing for a command, it should just have its key mentioned.  It looks like your idea would require changes to defvar-keymap.  Do you want to propose a patch?  We'd need some way to pass the hints in; perhaps the macro could set a property on the command symbol as you initially proposed.