[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/undo-fu d26b64530a 02/82: Support undo/redo multiple times
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/undo-fu d26b64530a 02/82: Support undo/redo multiple times |
Date: |
Thu, 7 Jul 2022 12:04:46 -0400 (EDT) |
branch: elpa/undo-fu
commit d26b64530a2aa441bc7c9e8de1bdad64ef3e81ca
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Support undo/redo multiple times
- Redo number is clamped to the number of possible redo steps
before the initial undo step.
- Added 'undo-fu-only-redo-all' to redo up until the
first redo step.
---
readme.rst | 3 ++-
undo-fu.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/readme.rst b/readme.rst
index a9c8b43c3e..9818950dfe 100644
--- a/readme.rst
+++ b/readme.rst
@@ -33,10 +33,11 @@ The default emacs undo has two limitations this package
aims to resolve,
Usage
=====
-This package exposes two functions:
+This package exposes the following functions:
- ``undo-fu-only-undo``
- ``undo-fu-only-redo``
+- ``undo-fu-only-redo-all``
You will need to make these to keys yourself.
diff --git a/undo-fu.el b/undo-fu.el
index c320807c62..c5b4c74942 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -65,11 +65,49 @@ Argument LIST compatible list `buffer-undo-list'."
list)
-(defun undo-fu-only-redo ()
- "Redo an action until the initial undo action.
+(defun undo-fu--count-step-to-other (list list-to-find count-limit)
+ "Get the next undo step in the list.
+
+Argument LIST compatible list `buffer-undo-list'.
+Argument LIST-TO-FIND the list to search for.
+Argument COUNT-LIMIT don't count past his value.
+
+Returns the number of steps to reach this list."
+ (let ((count 0))
+ (while (and list (not (eq list list-to-find)) (< count count-limit))
+ (setq list (undo-fu--next-step list))
+ (setq count (1+ count)))
+ count))
+
+(defun undo-fu--count-redo-available (list-to-find count-limit)
+ "Count the number of redo steps until a previously stored undo step.
+
+Argument LIST-TO-FIND count the steps up until this undo step.
+Argument COUNT-LIMIT don't count past his value.
+
+Returns the number of steps to reach this list."
+ (undo-fu--count-step-to-other
+ (if (or (eq pending-undo-list t) (member last-command '(undo
undo-fu-only-undo)))
+ (undo-fu--next-step buffer-undo-list)
+ pending-undo-list)
+ list-to-find count-limit))
+
+(defun undo-fu-only-redo-all ()
+ "Redo all actions until the initial undo step.
wraps the `undo' function."
- (interactive)
+ (interactive "*")
+ (unless undo-fu--checkpoint
+ (user-error "Redo end-point not found!"))
+ (undo-fu-only-redo (undo-fu--count-redo-available undo-fu--checkpoint
most-positive-fixnum)))
+
+(defun undo-fu-only-redo (&optional arg)
+ "Redo an action until the initial undo action.
+
+wraps the `undo' function.
+
+Optional argument ARG The number of steps to redo."
+ (interactive "*p")
(let*
( ;; Assign for convenience.
@@ -114,10 +152,16 @@ wraps the `undo' function."
(t
;; No change.
last-command)))
+ (steps
+ (if (numberp arg)
+ (if (and undo-fu--respect undo-fu--checkpoint)
+ (undo-fu--count-redo-available undo-fu--checkpoint arg)
+ arg)
+ 1))
(success
(condition-case err
(progn
- (undo)
+ (undo steps)
t)
(user-error (message "%s" (error-message-string err))))))
(when success
@@ -128,11 +172,13 @@ wraps the `undo' function."
(setq this-command 'undo-fu-only-redo))
-(defun undo-fu-only-undo ()
+(defun undo-fu-only-undo (&optional arg)
"Undo the last action.
-wraps the `undo-only' function."
- (interactive)
+wraps the `undo-only' function.
+
+Optional argument ARG the number of steps to undo."
+ (interactive "*p")
(let*
( ;; Assign for convenience.
@@ -161,10 +207,11 @@ wraps the `undo-only' function."
(t
;; No change.
last-command)))
+ (steps (or arg 1))
(success
(condition-case err
(progn
- (undo-only)
+ (undo-only steps)
t)
(user-error (message "%s" (error-message-string err)))
(error (message "%s" (error-message-string err))))))
- [nongnu] elpa/undo-fu e3e6750c95 37/82: readme: update to reference other packages, (continued)
- [nongnu] elpa/undo-fu e3e6750c95 37/82: readme: update to reference other packages, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu afa5685743 39/82: Cleanup: minor improvements to comments and error strings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu d5dd79c454 40/82: readme: add link to melpa, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu ea41b40601 54/82: Use 'undo' instead of 'undo-only' when unconstrained mode is in use, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 7fc9505561 61/82: Update evil-mode section in readme, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 8c461a00a0 51/82: Cleanup: comments, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 34b27c01da 66/82: Cleanup: use constant instead of local-variable for command list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 7ec3cc558e 68/82: Cleanup: use defgroup, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 71c474e29f 71/82: Cleanup: docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu a2241d3b52 76/82: Cleanup: simplify unconstrained undo checks, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu d26b64530a 02/82: Support undo/redo multiple times,
ELPA Syncer <=
- [nongnu] elpa/undo-fu 374a62cba0 08/82: Disable undo-in-region support, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu be82f88630 07/82: Add installation section, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 9cc8c64f16 12/82: Merge branch 'patch-1' into 'master', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 6f876014dc 14/82: Cleanup: complete doc string for message override macro, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 769789d742 17/82: Add autoload cookie, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu c5bb7b0402 22/82: Evil Mode: mark undo commands not to repeat, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu fd2e9952f9 31/82: Merge branch 'compiler-warnings' into 'master', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu c2be4ae43e 41/82: Cleanup: blank lines, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu d03de12298 44/82: Cleanup: use the term 'checkpoint' instead of 'end-point', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 2cba1903f3 45/82: Cleanup: improve 'undo-fu-disable-checkpoint' messages, ELPA Syncer, 2022/07/07