Function: undo-redo

undo-redo is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(undo-redo &optional ARG)

Documentation

Undo the last ARG undos, i.e., redo the last ARG changes.

Interactively, ARG is the prefix numeric argument and defaults to 1.

View in manual

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun undo-redo (&optional arg)
  "Undo the last ARG undos, i.e., redo the last ARG changes.
Interactively, ARG is the prefix numeric argument and defaults to 1."
  (interactive "*p")
  (cond
   ((not (undo--last-change-was-undo-p buffer-undo-list))
    (user-error "No undone changes to redo"))
   (t
    (let* ((ul buffer-undo-list)
           (new-ul
            (let ((undo-in-progress t))
              (while (and (consp ul) (eq (car ul) nil))
                (setq ul (cdr ul)))
              (primitive-undo (or arg 1) ul)))
           (new-pul (undo--last-change-was-undo-p new-ul)))
      (message "Redo%s" (if undo-in-region " in region" ""))
      (setq this-command 'undo)
      (setq pending-undo-list new-pul)
      (setq buffer-undo-list new-ul)))))