Function: repeat-post-hook

repeat-post-hook is a byte-compiled function defined in repeat.el.gz.

Signature

(repeat-post-hook)

Documentation

Function run after commands to set transient keymap for repeatable keys.

Source Code

;; Defined in /usr/src/emacs/lisp/repeat.el.gz
(defun repeat-post-hook ()
  "Function run after commands to set transient keymap for repeatable keys."
  (let ((was-in-progress repeat-in-progress))
    (setq repeat-in-progress nil)
    (when repeat-mode
      (let ((rep-map (or repeat-map (repeat--command-property 'repeat-map))))
        (when rep-map
          (when (and (symbolp rep-map) (boundp rep-map))
            (setq rep-map (symbol-value rep-map)))
          (let ((map (copy-keymap rep-map)))

            (when (and
                   ;; Detect changes in the minibuffer state to allow repetitions
                   ;; in the same minibuffer, but not when the minibuffer is activated
                   ;; in the middle of repeating sequence (bug#47566).
                   (or (< (minibuffer-depth) (car repeat--prev-mb))
                       (eq current-minibuffer-command (cdr repeat--prev-mb)))
                   (or (not repeat-keep-prefix) prefix-arg)
                   (repeat-check-key last-command-event map))

              ;; Messaging
              (unless prefix-arg
                (funcall repeat-echo-function map))

              ;; Adding an exit key
              (when repeat-exit-key
                (define-key map repeat-exit-key 'ignore))

              (when (and repeat-keep-prefix (not prefix-arg))
                (setq prefix-arg current-prefix-arg))

              (setq repeat-in-progress t)
              (let ((exitfun (set-transient-map map)))

                (when repeat-exit-timer
                  (cancel-timer repeat-exit-timer)
                  (setq repeat-exit-timer nil))

                (let* ((prop (repeat--command-property 'repeat-exit-timeout))
                       (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout))))
                  (when timeout
                    (setq repeat-exit-timer
                          (run-with-idle-timer
                           timeout nil
                           (lambda ()
                             (setq repeat-in-progress nil)
                             (funcall exitfun)
                             (funcall repeat-echo-function nil))))))))))))

    (setq repeat-map nil)
    (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command))
    (when (and was-in-progress (not repeat-in-progress))
      (when repeat-exit-timer
        (cancel-timer repeat-exit-timer)
        (setq repeat-exit-timer nil))
      (funcall repeat-echo-function nil))))