branch: elpa/undo-fu
commit 1d60424680a2eff6a20f0d462057b2fc1bc7f5f6
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Raise error when using undo-fu commands when undo has been disabled
While in this case nothing useful can be done,
raise an error since this was failing to set the checkpoint
with an unhelpful error.
---
changelog.rst | 5 +++++
undo-fu.el | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/changelog.rst b/changelog.rst
index 08913245fe..0bd9d09ece 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,11 @@
Change Log
##########
+- In development
+
+ - Raise an error when using undo commands when undo has been disabled for
the buffer.
+ *(was failing to set the checkpoint in this case).*
+
- Version 0.3 (2020-03-03)
- Support non-destructive commands between undo/redo actions without
breaking the chain.
diff --git a/undo-fu.el b/undo-fu.el
index 283f529bfb..eba23d64ed 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -111,6 +111,11 @@ Optional argument BODY runs with the message suffix."
(apply ,message-orig (append (list (concat arg "%s")) args (list
,suffix))))))
,@body)))
+(defun undo-fu--undo-enabled-or-error ()
+ "Raise a user error when undo is disabled."
+ (when (eq t buffer-undo-list)
+ (user-error "Undo has been disabled!")))
+
(defun undo-fu--next-step (list)
"Get the next undo step in the list.
@@ -196,6 +201,8 @@ wraps the `undo' function.
Optional argument ARG The number of steps to redo."
(interactive "*p")
+ ;; Raise error since we can't do anything useful in this case.
+ (undo-fu--undo-enabled-or-error)
(let*
( ;; Assign for convenience.
@@ -329,6 +336,8 @@ wraps the `undo-only' function.
Optional argument ARG the number of steps to undo."
(interactive "*p")
+ ;; Raise error since we can't do anything useful in this case.
+ (undo-fu--undo-enabled-or-error)
(let*
( ;; Assign for convenience.