Function: describe-repeat-maps

describe-repeat-maps is an interactive and byte-compiled function defined in repeat.el.gz.

Signature

(describe-repeat-maps)

Documentation

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(var)/repeat-mode(fun) is enabled. Commands that can be repeated this way must have their symbol to have the repeat-map property whose value specified a keymap.

View in manual

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/repeat.el.gz
(defun describe-repeat-maps ()
  "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))
    (help-setup-xref (list #'describe-repeat-maps)
                     (called-interactively-p 'interactive))
    (let ((keymaps nil))
      (all-completions
       "" obarray (lambda (s)
                    (and (commandp s)
                         (get s 'repeat-map)
                         (push s (alist-get (get s 'repeat-map) keymaps)))))
      (with-help-window (help-buffer)
        (with-current-buffer standard-output
          (setq-local outline-regexp "[*]+")
          (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))
                                                     (symbolp (car b)))
                                            (string< (car a) (car b))))))
            (insert (format-message "\f\n* `%s'\n" (car keymap)))
            (when (symbolp (car keymap))
              (insert (substitute-command-keys (format-message "\\{%s}" (car keymap)))))

            (let* ((map (if (symbolp (car keymap))
                            (symbol-value (car keymap))
                          (car keymap)))
                   (repeat-commands (cdr keymap))
                   map-commands commands-enter commands-exit commands-continue)
              (cl--map-keymap-recursively
               (lambda (_key cmd)
                 (when (symbolp cmd) (push cmd map-commands)))
               map)
              (setq map-commands (seq-uniq map-commands))
              (setq commands-continue
                    (seq-filter (lambda (s) (memq (car keymap)
                                                  (get s 'repeat-continue)))
                                map-commands))
              (setq commands-enter
                    (seq-difference repeat-commands map-commands))
              (setq commands-exit
                    (seq-difference (seq-difference map-commands repeat-commands)
                                    commands-continue))

              (when (or commands-enter commands-exit commands-continue)
                (when commands-enter
                  (insert "\n** Entered with:\n\n")
                  (fill-region-as-paragraph
                   (point)
                   (progn
                     (insert (mapconcat (lambda (cmd)
                                          (format-message "`%s'" cmd))
                                        (sort commands-enter #'string<)
                                        ", "))
                     (point)))
                  (insert "\n"))
                (when commands-continue
                  (insert "\n** Continued only with:\n\n")
                  (fill-region-as-paragraph
                   (point)
                   (progn
                     (insert (mapconcat (lambda (cmd)
                                          (format-message "`%s'" cmd))
                                        (sort commands-continue #'string<)
                                        ", "))
                     (point)))
                  (insert "\n"))
                (when commands-exit
                  (insert "\n** Exited with:\n\n")
                  (fill-region-as-paragraph
                   (point)
                   (progn
                     (insert (mapconcat (lambda (cmd)
                                          (format-message "`%s'" cmd))
                                        (sort commands-exit #'string<)
                                        ", "))
                     (point)))
                  (insert "\n")))))

          ;; Hide ^Ls.
          (goto-char (point-min))
          (while (search-forward "\n\f\n" nil t)
            (put-text-property (1+ (match-beginning 0)) (1- (match-end 0))
                               'invisible t)))))))