GNU bug report logs -
#70576
[PATCH] `repeat-echo-message-string': support repeat keymap "hints"
Previous Next
Reported by: JD Smith <jdtsmith <at> gmail.com>
Date: Thu, 25 Apr 2024 22:33:05 UTC
Severity: normal
Tags: fixed, moreinfo, patch
Found in version 30.0.5
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]
This bug report was last modified 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.