bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: JD Smith
Subject: bug#70576: [PATCH] `repeat-echo-message-string': support repeat keymap "hints"
Date: Thu, 25 Apr 2024 18:31:17 -0400

repeat-mode is excellent for informal and very lightweight modal interfaces (great article).  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]