(repeat-echo-message-string): Reuse 'r-m-c' prompt formatting
authorEshel Yaron <me@eshelyaron.com>
Wed, 8 May 2024 16:05:20 +0000 (18:05 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 May 2024 16:05:20 +0000 (18:05 +0200)
Now that 'repeat-mode' supports adding labels ("hints") next to
available keys, its prompt is very similar in its structure to
what we have in 'read-multiple-choice' (a list of labeled keys).
To make the two interfaces more consistent, reuse the prompt
formatting that 'read-multiple-choice' employs.

See short discussion at
https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg00467.html

* lisp/repeat.el (repeat-echo-message-string): Use
'rmc--add-key-description' to format keys and their labels.

lisp/repeat.el

index 412afc35ba73197cda74fbb4237d3972f5fb5128..374a925d70c79e65504c8096d4d3b65a1ce4ece5 100644 (file)
@@ -558,14 +558,14 @@ This function can be used to force exit of repetition while it's active."
     (format-message
      "Repeat with %s%s"
      (mapconcat (lambda (key-cmd)
-                  (let* ((key (car key-cmd))
-                         (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) "")))))
+                  (let ((key (car key-cmd))
+                        (cmd (cdr key-cmd)))
+                    (if-let ((hint (and (symbolp cmd)
+                                        (get cmd 'repeat-hint))))
+                        ;; Reuse `read-multiple-choice' formatting.
+                        (cdr (rmc--add-key-description (list key hint)))
+                      (propertize (key-description (vector key))
+                                  'face 'read-multiple-choice-face))))
                 keys ", ")
      (if repeat-exit-key
          (substitute-command-keys