GNU bug report logs - #46515
Repeat mode

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Sun, 14 Feb 2021 18:54:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Matt Armstrong <matt <at> rfc20.org>
Cc: 46515 <at> debbugs.gnu.org
Subject: bug#46515: Repeat mode
Date: Mon, 15 Feb 2021 11:17:31 +0200
[Message part 1 (text/plain, inline)]
> 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.

[repeat-message.patch (text/x-diff, inline)]
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))))))

This bug report was last modified 4 years and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.