all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eshel Yaron <me@eshelyaron.com>
To: emacs-devel@gnu.org
Cc: Juri Linkov <juri@linkov.net>, JD Smith <jdtsmith@gmail.com>
Subject: Re: master 0023891e842: Support hints in the :repeat keyword of defvar-keymap for repeat-mode
Date: Mon, 06 May 2024 23:27:06 +0200	[thread overview]
Message-ID: <m15xvqd42d.fsf@dazzs-mbp.kpn> (raw)
In-Reply-To: <20240502064749.54E89C1F9D4@vcs2.savannah.gnu.org> (Juri Linkov's message of "Thu, 2 May 2024 02:47:49 -0400 (EDT)")

Hi,

Juri Linkov <juri@jurta.org> writes:

> branch: master
> commit 0023891e84285c2ea2a8029f479135f792c9d1e9
> Author: Juri Linkov <juri@linkov.net>
> Commit: Juri Linkov <juri@linkov.net>
>
>     Support hints in the :repeat keyword of defvar-keymap for repeat-mode
>
>     * lisp/keymap.el (defvar-keymap): Add :hints to the :repeat keyword.
>     Put the property 'repeat-hint' on the command symbol.
>
>     * lisp/repeat.el (repeat-echo-message-string): Show hint strings
>     defined with the property 'repeat-hint' on the command symbol (bug#70576).

Thank you for this nice addition.  A couple of thoughts I had after
trying it out:

The need to repeat the name of the command in order to specify its label
("hint") makes the keymap definition twice as long and prone to errors.
For example, after adding "hints" to one of my keymaps I got:

--8<---------------cut here---------------start------------->8---
(defvar-keymap esy/emms-map
  :doc "My keymap for EMMS commands."
  :prefix 'esy/emms-map
  :repeat (:hints ((emms-next          . "Next")
                   (emms-previous      . "Previous")
                   (emms-stop          . "Stop")
                   (emms-seek-backward . "backward")
                   (emms-seek-forward  . "forward")
                   (emms-seek          . "seek")
                   (emms-show          . "show")
                   (emms-pause         . "pause")
                   (emms-start         . "start")
                   (emms-seek-to       . "to")))
  "N" #'emms-next
  "P" #'emms-previous
  "S" #'emms-stop
  "b" #'emms-seek-backward
  "f" #'emms-seek-forward
  "k" #'emms-seek
  "m" #'emms-show
  "p" #'emms-pause
  "s" #'emms-start
  "t" #'emms-seek-to)
--8<---------------cut here---------------end--------------->8---

I don't have a great idea for an alternative interface off the top of my
head, but if there's a way to avoid this duplication I think it would be
a significant improvement.

Lastly, it could be nice to make the appearance of the prompt more in
line with the read-multiple-choice prompt, which is conceptually very
similar.  Crucially, if the key is a character that occurs in the label,
it's better, IMO, to highlight the first occurrence of that character in
the label (as r-m-c does) than to prefix the label with that character.
We can reuse rmc--add-key-description for that purpose, as follows:

diff --git a/lisp/repeat.el b/lisp/repeat.el
index 412afc35ba7..cd70c1a7f2d 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -562,10 +562,7 @@ repeat-echo-message-string
                          (cmd (cdr key-cmd))
                          (hint (when (symbolp cmd)
                                  (get cmd 'repeat-hint))))
-                    (substitute-command-keys
-                     (format "\\`%s'%s"
-                             (key-description (vector key))
-                             (if hint (format ":%s" hint) "")))))
+                    (cdr (rmc--add-key-description (list key (or hint ""))))))
                 keys ", ")
      (if repeat-exit-key
          (substitute-command-keys



       reply	other threads:[~2024-05-06 21:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <171463246897.31562.10434330482523385662@vcs2.savannah.gnu.org>
     [not found] ` <20240502064749.54E89C1F9D4@vcs2.savannah.gnu.org>
2024-05-06 21:27   ` Eshel Yaron [this message]
2024-05-07  6:27     ` master 0023891e842: Support hints in the :repeat keyword of defvar-keymap for repeat-mode Juri Linkov
2024-05-07 11:56       ` JD Smith
2024-05-07 17:13         ` Eshel Yaron
2024-05-07 17:20           ` Juri Linkov
2024-05-08 16:40             ` Eshel Yaron

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=m15xvqd42d.fsf@dazzs-mbp.kpn \
    --to=me@eshelyaron.com \
    --cc=emacs-devel@gnu.org \
    --cc=jdtsmith@gmail.com \
    --cc=juri@linkov.net \
    /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.