Created
June 7, 2020 19:54
-
-
Save casouri/610c21a4503e96184956bf19aa930667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(unless (boundp 'undo--last-change-was-undo-p) | |
(defun undo--last-change-was-undo-p (undo-list) | |
(while (and (consp undo-list) (eq (car undo-list) nil)) | |
(setq undo-list (cdr undo-list))) | |
(gethash undo-list undo-equiv-table)) | |
(defun undo-redo (&optional arg) | |
"Undo the last ARG undos." | |
(interactive "*p") | |
(cond | |
((not (undo--last-change-was-undo-p buffer-undo-list)) | |
(user-error "No undo to undo")) | |
(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 arg 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)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment