all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints"
@ 2024-04-25 22:31 JD Smith
  2024-04-26  6:06 ` Juri Linkov
  0 siblings, 1 reply; 13+ messages in thread
From: JD Smith @ 2024-04-25 22:31 UTC (permalink / raw)
  To: 70576

[-- 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 --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-05-03  7:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-25 22:31 bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints" JD Smith
2024-04-26  6:06 ` 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

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.