[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46515: Repeat mode
From: |
Juri Linkov |
Subject: |
bug#46515: Repeat mode |
Date: |
Mon, 15 Feb 2021 11:17:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
> First thing: neat idea, and don't listen to me. :-)
Thanks, I really appreciate your help.
> Have you thought about making it more clear to the user that their keys
> are now doing different things? Most successful "modal" interfaces I
> have seen have clear indicators.
I have already thought about using prefix-command-echo-keystrokes-functions,
but failed to do this, so abandoned this attempt. I did not realize
it's possible to do this simply with messages like you pointed out here :-)
> One idea is to look at the other places in Emacs that already use
> `set-transient-map' in this way and try to be "at least as good" as
> those. `kmacro' and `indent-rigidly' are two reasonable examples. They
> print messages when active that describe the newly active key bindings.
I use `indent-rigidly' many times every day, but never noticed that
it prints the message
Indent region with <left>, <right>, S-<left>, or S-<right>.
It goes unnoticed maybe because it's displayed only once at its activation.
> repeat.el doesn't describe the key binding, but it does say a repeat
> mode is active. Kmacro is so smart that it aranges for the repeat key to
> be based on whatever key the command was invoked with.
Unlike `indent-rigidly', `kmacro' message
(Type e to repeat macro)
is displayed on every keypress, so it's a good example.
Now added in the following patch applied over the previous patch.
> As far as this general approach for creating small transient modes, I
> can't help but think it is too low level. An approach that had a bit
> more scafolding to it would let Emacs' help system describe it, and it
> might allow for a consistent way for Emacs to indicade they are active
> --- similar to how the conventions under major and minor work for
> "heavier" modes.
Currently I have no idea how this could be generalized. But simply
describing it in the help system should be quite easy to do,
so e.g. 'C-h k C-x o' could check for the command's repeat keymap
and add a help string about its repeatability.
diff --git a/lisp/repeat.el b/lisp/repeat.el
index 896a95197a..3c8be63c84 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -360,6 +360,9 @@ repeat-post-hook
(when (boundp repeat-map)
(setq repeat-map (symbol-value repeat-map)))
(let ((map (copy-keymap repeat-map)))
+ (let (keys)
+ (map-keymap (lambda (key _) (push (key-description (vector key))
keys)) map)
+ (message "To repeat type %s" (mapconcat #'identity keys ", ")))
(when repeat-exit-key
(define-key map repeat-exit-key 'ignore))
(set-transient-map map))))))