emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/undo-fu d561fa8e0c 23/82: Fix #2 Support linear redo


From: ELPA Syncer
Subject: [nongnu] elpa/undo-fu d561fa8e0c 23/82: Fix #2 Support linear redo
Date: Thu, 7 Jul 2022 12:04:50 -0400 (EDT)

branch: elpa/undo-fu
commit d561fa8e0c752c4000daba3931dd8525998a0665
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix #2 Support linear redo
    
    'undo-fu-only-redo' never performs an undo
    (unless running in unconstrained mode).
---
 readme.rst |  2 +-
 undo-fu.el | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/readme.rst b/readme.rst
index 1e35085c9a..9f9773ad97 100644
--- a/readme.rst
+++ b/readme.rst
@@ -2,7 +2,7 @@
 Undo Fu
 #######
 
-Simple, stable undo with redo for emacs.
+Simple, stable linear undo with redo for Emacs.
 
 Unlike alternatives, this provides redo functionality with emacs own undo,
 without losing access to the full undo history emacs supports
diff --git a/undo-fu.el b/undo-fu.el
index 53b9af8f4a..49bb755310 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -199,6 +199,26 @@ Optional argument ARG The number of steps to redo."
         "Redo end-point hit (%s to step over it)"
         (substitute-command-keys "\\[keyboard-quit]")))
 
+    (when undo-fu--respect
+      ;; Implement "linear" undo.
+      ;; So undo/redo chains before the undo checkpoint never redo an undo 
step.
+      ;;
+      ;; Without this, redo is still usable, it's just that after 
undo,redo,undo, ...
+      ;; the redo action will undo, which isn't so useful.
+      ;; This makes redo-only the reverse of undo-only.
+
+      (when (not (eq t pending-undo-list))
+        ;; Skip to the last matching redo step before the checkpoint.
+        (let
+          (
+            (list pending-undo-list)
+            (checkpoint-length (length undo-fu--checkpoint)))
+          (while
+            (and
+              (setq list (gethash list undo-equiv-table))
+              (eq (last list checkpoint-length) undo-fu--checkpoint))
+            (setq pending-undo-list list)))))
+
     (let*
       (
         ;; Important to clamp before assigning 'last-command'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]