@findex describe-repeat-maps
@vindex repeat-exit-key
@vindex repeat-exit-timeout
- Also you can activate @code{repeat-mode} that temporarily enables a
-transient mode with short keys after a limited number of commands.
-Currently supported shorter key sequences are @kbd{C-x u u} instead of
-@kbd{C-x u C-x u} to undo many changes, @kbd{C-x o o} instead of
-@kbd{C-x o C-x o} to switch several windows, @kbd{C-x @{ @{ @} @} ^ ^
-v v} to resize the selected window interactively, @kbd{M-g n n p p} to
-navigate @code{next-error} matches, @kbd{C-x ] ] [ [} to navigate
-through pages, and other keys listed by @code{describe-repeat-maps}.
-Any other key exits transient mode and then is executed normally. The
-user option @code{repeat-exit-key} defines an additional key to exit
-this transient mode. Also it's possible to break the repetition chain
-automatically after some idle time by customizing the user option
+ You can also activate @code{repeat-mode} which allows repeating
+commands bound to sequences of two or more keys by typing a single
+character. For example, after typing @w{@kbd{C-x u}} (@code{undo},
+@pxref{Undo}) to undo the most recent edits, you can undo many more
+edits by typing @w{@kbd{u u u@dots{}}}. Similarly, type @w{@kbd{C-x o
+o o@dots{}}} instead of @w{@kbd{C-x o C-x o C-x o@dots{}}} to switch
+to the window several windows away. This works by entering a
+transient repeating mode after you type the full key sequence that
+invokes the command; the single-key shortcuts are shown in the echo
+area.
+
+Only some commands support repetition in @code{repeat-mode}; type
+@w{@kbd{M-x describe-repeat-maps @key{RET}}} to see which ones.
+
+The single-character shortcuts enabled by the transient repeating mode
+do not need to be identical: for example, after typing @w{@kbd{C-x
+@{}}, either @kbd{@{} or @kbd{@}} or @kbd{^} or @kbd{v}, or any series
+that mixes these characters in any order, will resize the selected
+window in respective ways. Similarly, after @w{@kbd{M-g n}} or
+@kbd{M-g p}, typing any sequence of @kbd{n} and/or @kbd{p} in any mix
+will repeat @code{next-error} and @code{previous-error} to navigate in
+a @file{*compilation*} or @file{*grep*} buffer (@pxref{Compilation
+Mode}).
+
+Typing any key other than those defined to repeat the previous command
+exits the transient repeating mode, and then the key you typed is
+executed normally. You can also define a key which will exit the
+transient repeating mode @emph{without} executing the key which caused
+the exit. To this end, customize the user option
+@code{repeat-exit-key} to name a key; one natural value is @key{RET}.
+Finally, it's possible to break the repetition chain automatically
+after some amount of idle time: customize the user option
@code{repeat-exit-timeout} to specify the idle time in seconds after
-which this transient mode will be turned off.
+which this transient repetition mode will be turned off automatically.
:version "28.1")
(defcustom repeat-exit-timeout nil
- "Break the repetition chain of keys after specified timeout.
+ "Break the repetition chain of keys after specified amount of idle time.
When a number, exit the transient repeating mode after idle time
of the specified number of seconds.
You can also set the property `repeat-exit-timeout' on the command symbol.
(defcustom repeat-check-key t
"Whether to check that the last key exists in the repeat map.
-When non-nil and the last typed key (with or without modifiers)
-doesn't exist in the keymap attached by the `repeat-map' property,
-then don't activate that keymap for the next command. So only the
-same keys among repeatable keys are allowed in the repeating sequence.
-For example, with a non-nil value, only \\`C-x u u' repeats undo,
-whereas \\`C-/ u' doesn't.
+When non-nil, and the last typed key (with or without modifiers)
+doesn't exist in the keymap specified by the `repeat-map' property
+of the command, don't activate that keymap for the next command.
+Thus, when this is non-nil, only the same keys among repeatable
+keys are allowed in the repeating sequence. For example, with a
+non-nil value, only \\`C-x u u' repeats undo, whereas \\`C-/ u' doesn't.
You can also set the property `repeat-check-key' on the command symbol.
This property can override the value of this variable.
(defcustom repeat-echo-function #'repeat-echo-message
"Function to display a hint about available keys.
-Function is called after every repeatable command with one argument:
+The function is called after every repeatable command with one argument:
a repeating map, or nil after deactivating the transient repeating mode.
You can use `add-function' for multiple functions simultaneously."
:type '(choice (const :tag "Show hints in the echo area"
;;;###autoload
(define-minor-mode repeat-mode
"Toggle Repeat mode.
-When Repeat mode is enabled, and the command symbol has the property named
-`repeat-map', this map is activated temporarily for the next command.
+When Repeat mode is enabled, certain commands bound to multi-key
+sequences can be repeated by typing a single key, after typing the
+full key sequence once.
+The commands which can be repeated like that are those whose symbol
+ has the property `repeat-map' which specifies a keymap of single
+keys for repeating.
See `describe-repeat-maps' for a list of all repeatable commands."
:global t :group 'repeat
(if (not repeat-mode)
rep-map))))
(defun repeat-check-key (key map)
- "Check if the last key is suitable to activate the repeating MAP."
+ "Check if the last KEY is suitable for activating the repeating MAP."
(let* ((prop (repeat--command-property 'repeat-check-key))
(check-key (unless (eq prop 'no) (or prop repeat-check-key))))
(or (not check-key)
"Previous minibuffer state.")
(defun repeat-check-map (map)
- "Decides whether MAP can be used for the next command."
+ "Decide whether MAP can be used for the next command."
(and map
;; Detect changes in the minibuffer state to allow repetitions
;; in the same minibuffer, but not when the minibuffer is activated
(setq repeat-exit-function nil)))
(defun repeat-echo-message-string (keymap)
- "Return a string with a list of repeating keys."
+ "Return a string with the list of repeating keys in KEYMAP."
(let (keys)
(map-keymap (lambda (key cmd) (and cmd (push key keys))) keymap)
(format-message "Repeat with %s%s"
""))))
(defun repeat-echo-message (keymap)
- "Display available repeating keys in the echo area."
+ "Display in the echo area the repeating keys defined by KEYMAP.
+See `repeat-echo-function' to enable/disable."
(let ((message-log-max nil))
(if keymap
(let ((message (repeat-echo-message-string keymap)))
"String displayed in the mode line in repeating mode.")
(defun repeat-echo-mode-line (keymap)
- "Display the repeat indicator in the mode line."
+ "Display the repeat indicator in the mode line.
+KEYMAP should be non-nil, but is otherwise ignored.
+See `repeat-echo-function' to enable/disable."
(if keymap
(unless (assq 'repeat-in-progress mode-line-modes)
(add-to-list 'mode-line-modes (list 'repeat-in-progress
(declare-function help-fns--analyze-function "help-fns" (function))
(defun describe-repeat-maps ()
- "Describe mappings of commands repeatable by symbol property `repeat-map'.
-If `repeat-mode' is enabled, these keymaps determine which single key
-can be used to repeat a command invoked via a full key sequence."
+ "Describe transient keymaps installed for repeating multi-key commands.
+These keymaps enable repetition of commands bound to multi-key
+sequences by typing just one key, when `repeat-mode' is enabled.
+Commands that can be repeated this way must have their symbol
+to have the `repeat-map' property whose value specified a keymap."
(interactive)
(require 'help-fns)
(let ((help-buffer-under-preparation t))
(with-help-window (help-buffer)
(with-current-buffer standard-output
(setq-local outline-regexp "[*]+")
- (insert "A list of keymaps used by commands with the symbol property `repeat-map'.\n")
+ (insert "\
+A list of keymaps and their single-key shortcuts for repeating commands.
+Click on a keymap to see the commands repeatable by the keymap.\n")
(dolist (keymap (sort keymaps (lambda (a b)
(when (and (symbolp (car a))