Function: repeat-echo-message-string

repeat-echo-message-string is a byte-compiled function defined in repeat.el.gz.

Signature

(repeat-echo-message-string KEYMAP)

Documentation

Return a string with the list of repeating keys in KEYMAP.

Source Code

;; Defined in /usr/src/emacs/lisp/repeat.el.gz
(defun repeat-echo-message-string (keymap)
  "Return a string with the list of repeating keys in KEYMAP."
  (let (keys)
    (cl--map-keymap-recursively
     (lambda (key cmd) (and cmd (push (cons (copy-sequence key) cmd) keys)))
     keymap)
    (format-message
     "Repeat with %s%s"
     (mapconcat (lambda (key-cmd)
                  (let ((key (car key-cmd))
                        (cmd (cdr key-cmd)))
                    (if-let* ((hint (and (symbolp cmd)
                                         (get cmd 'repeat-hint)))
                              (last (aref key (1- (length key)))))
                        ;; Reuse `read-multiple-choice' formatting.
                        (if (= (length key) 1)
                            (cdr (rmc--add-key-description (list last hint)))
                          (format "%s (%s)"
                                  (propertize (key-description key)
                                              'face 'read-multiple-choice-face)
                                  (cdr (rmc--add-key-description
                                        (list (event-basic-type last) hint)))))
                      (propertize (key-description key)
                                  'face 'read-multiple-choice-face))))
                keys ", ")
     (if repeat-exit-key
         (substitute-command-keys
          (format ", or exit with \\`%s'"
                  (if (key-valid-p repeat-exit-key)
                      repeat-exit-key
                    (key-description repeat-exit-key))))
       ""))))