all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: 70576@debbugs.gnu.org
Subject: bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints"
Date: Thu, 25 Apr 2024 18:31:17 -0400	[thread overview]
Message-ID: <45C35B69-6DA8-4212-BD87-50B2A3959A86@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]

repeat-mode is excellent for informal and very lightweight modal interfaces (great article <https://karthinks.com/software/it-bears-repeating/>).  One limitation it has compared to other such interfaces is it only mentions the keys which can be repeated, without providing hints about what they do.  

A simple patch to `repeat-echo-message-strings' to support displaying a string for keymap definitions of form (STRING . DEFN) is below.  It works nicely to provide "hints" after each repeat key, if the keymap includes them.

Example usage:

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

Example prompt (after one invocation of `expreg-expand'): 

 Repeat with \:expand, |:contract

It might also be useful to provide a custom variable by which a user can disable hint strings, for the experts/minimalists..

Patch:

--- repeat_old.el	2024-04-25 18:22:59
+++ repeat.el	2024-04-25 18:09:11
@@ -553,12 +553,20 @@
 (defun repeat-echo-message-string (keymap)
   "Return a string with the list of repeating keys in KEYMAP."
   (let (keys)
-    (map-keymap (lambda (key cmd) (and cmd (push key keys))) keymap)
+    (map-keymap (lambda (key cmd)
+		  (if (consp cmd)
+		      (push (cons (car cmd) key) keys)
+		    (when cmd (push key keys))))
+		keymap)
     (format-message "Repeat with %s%s"
                     (mapconcat (lambda (key)
-                                 (substitute-command-keys
-                                  (format "\\`%s'"
-                                          (key-description (vector key)))))
+				 (let* ((cmd (when (consp key) (format ":%s" (car key)))))
+				   (if (consp key) (setq key (cdr key)))
+				   (concat
+				    (substitute-command-keys
+				     (format "\\`%s'"
+					     (key-description (vector key))))
+				    cmd)))
                                keys ", ")
                     (if repeat-exit-key
                         (substitute-command-keys


[-- Attachment #2: Type: text/html, Size: 22197 bytes --]

             reply	other threads:[~2024-04-25 22:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 22:31 JD Smith [this message]
2024-04-26  6:06 ` bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints" Juri Linkov
2024-04-26 14:37   ` JD Smith
2024-04-28  6:58     ` Juri Linkov
2024-04-28 12:45       ` JD Smith
2024-04-28 16:38         ` Juri Linkov
2024-05-02  6:48           ` Juri Linkov
2024-05-02  7:16             ` Eli Zaretskii
2024-05-02 11:47               ` JD Smith
2024-05-02 16:16               ` Juri Linkov
2024-05-02 18:14                 ` Eli Zaretskii
2024-05-03  6:23                   ` Juri Linkov
2024-05-03  7:15                     ` Eli Zaretskii

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=45C35B69-6DA8-4212-BD87-50B2A3959A86@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=70576@debbugs.gnu.org \
    /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.