[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/undo-fu 88c4086e12 43/82: Add 'undo-fu-ignore-keyboard-qui
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/undo-fu 88c4086e12 43/82: Add 'undo-fu-ignore-keyboard-quit' & 'undo-fu-disable-checkpoint' |
Date: |
Thu, 7 Jul 2022 12:04:52 -0400 (EDT) |
branch: elpa/undo-fu
commit 88c4086e12707de2a125132f18f7586f23441b61
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Add 'undo-fu-ignore-keyboard-quit' & 'undo-fu-disable-checkpoint'
This is an option (off by default) that allows explicitly
activating non-linear behavior as 'keyboard-quit' could
be used for other reasons where it's possible to accidentally
activate non-linear behavior.
Resolves #6
---
changelog.rst | 5 +++++
readme.rst | 7 +++++++
undo-fu.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/changelog.rst b/changelog.rst
index ce37041db8..51579514e7 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,11 @@
Change Log
##########
+- In development.
+
+ - Add ``undo-fu-ignore-keyboard-quit`` option for explicit non-linear
behavior.
+ - Support using ``undo-fu-only-redo`` after regular ``undo`` / ``undo-only``.
+
- Version 0.2 (2020-01-12)
- Linear redo support (which wont undo).
diff --git a/readme.rst b/readme.rst
index 915c177465..f8a41cef82 100644
--- a/readme.rst
+++ b/readme.rst
@@ -37,6 +37,7 @@ This package exposes the following functions:
- ``undo-fu-only-undo``
- ``undo-fu-only-redo``
- ``undo-fu-only-redo-all``
+- ``undo-fu-disable-checkpoint`` (only needed when
``undo-fu-ignore-keyboard-quit`` is in use).
Key Bindings
@@ -83,6 +84,12 @@ Customization
When this boolean is ``t``, undoing with a selection
will use undo within this region.
+``undo-fu-ignore-keyboard-quit``
+ Don't use ``Ctrl-G`` (``keyboard-quit``) for non-linear behavior,
+ instead, use the ``undo-fu-disable-checkpoint`` command.
+
+ This was added for users who prefer to explicitly activate this behavior.
+ As ``keyboard-quit`` may be used for other reasons.
Limitations
diff --git a/undo-fu.el b/undo-fu.el
index 247037b1e1..efe14712f0 100644
--- a/undo-fu.el
+++ b/undo-fu.el
@@ -53,6 +53,13 @@ causing undo-fu to work with reduced functionality when a
selection exists."
:group 'undo-fu
:type 'boolean)
+(defcustom undo-fu-ignore-keyboard-quit nil
+ "When t, don't use `keyboard-quit' to disable linear undo/redo behavior.
+
+Instead, explicitly call `undo-fu-disable-checkpoint'."
+ :group 'undo-fu
+ :type 'boolean)
+
;; ---------------------------------------------------------------------------
;; Internal Variables
@@ -143,6 +150,28 @@ Returns the number of steps to reach this list or
COUNT-LIMIT."
;; ---------------------------------------------------------------------------
;; Public Functions
+;;;###autoload
+(defun undo-fu-disable-checkpoint ()
+ "Remove the undo-fu checkpoint, making all future actions unconstrained.
+
+This command is needed when `undo-fu-ignore-keyboard-quit' is t,
+since in this case `keyboard-quit' cannot be used
+to perform unconstrained undo/redo actions."
+ (interactive)
+ (message "Undo end-point cleared!")
+ (undo-fu--checkpoint-disable)
+
+ ;; Needed not to interfere with undo/redo stepping behavior.
+ (let*
+ ( ;; Assign for convenience.
+ (was-undo (not (null (member last-command '(undo undo-fu-only-undo)))))
+ (was-redo (not (null (member last-command '(undo-fu-only-redo)))))
+ (was-undo-or-redo (or was-undo was-redo)))
+
+ (when was-undo-or-redo
+ (setq this-command last-command)
+ (setq real-this-command real-last-command))))
+
;;;###autoload
(defun undo-fu-only-redo-all ()
"Redo all actions until the initial undo step.
@@ -167,7 +196,11 @@ Optional argument ARG The number of steps to redo."
( ;; Assign for convenience.
(was-undo (not (null (member last-command '(undo undo-fu-only-undo)))))
(was-redo (not (null (member last-command '(undo-fu-only-redo)))))
- (was-undo-or-redo (or was-undo was-redo)))
+ (was-undo-or-redo (or was-undo was-redo))
+ (undo-fu-quit-command
+ (if undo-fu-ignore-keyboard-quit
+ 'undo-fu-disable-checkpoint
+ 'keyboard-quit)))
;; Reset the option to not respect the checkpoint
;; after running non-undo related commands.
@@ -190,7 +223,7 @@ Optional argument ARG The number of steps to redo."
;; This allows explicitly over-stepping the boundary,
;; in cases when users want to bypass this constraint.
(when undo-fu--respect
- (when (string-equal last-command 'keyboard-quit)
+ (when (member last-command (list undo-fu-quit-command
'undo-fu-disable-checkpoint))
(undo-fu--checkpoint-disable)
(message "Redo end-point stepped over!")))
@@ -234,8 +267,8 @@ Optional argument ARG The number of steps to redo."
;; Ensure the next steps is a redo action.
(when (zerop steps-test)
(user-error
- "Redo step not found (%s to ignore)"
- (substitute-command-keys "\\[keyboard-quit]")))
+ "Redo end-point reached (%s to ignore)"
+ (substitute-command-keys (format "\\[%s]" (symbol-name
undo-fu-quit-command)))))
steps-test)
@@ -282,7 +315,11 @@ Optional argument ARG the number of steps to undo."
( ;; Assign for convenience.
(was-undo (not (null (member last-command '(undo undo-fu-only-undo)))))
(was-redo (not (null (member last-command '(undo-fu-only-redo)))))
- (was-undo-or-redo (or was-undo was-redo)))
+ (was-undo-or-redo (or was-undo was-redo))
+ (undo-fu-quit-command
+ (if undo-fu-ignore-keyboard-quit
+ 'undo-fu-disable-checkpoint
+ 'keyboard-quit)))
;; Reset the option to not respect the checkpoint
;; after running non-undo related commands.
@@ -305,9 +342,10 @@ Optional argument ARG the number of steps to undo."
(deactivate-mark)))
;; Allow crossing the boundary, if we press [keyboard-quit].
- ;; This allows explicitly over-stepping the boundary, in cases where it's
needed.
+ ;; This allows explicitly over-stepping the boundary,
+ ;; in cases when users want to bypass this constraint.
(when undo-fu--respect
- (when (string-equal last-command 'keyboard-quit)
+ (when (member last-command (list undo-fu-quit-command
'undo-fu-disable-checkpoint))
(undo-fu--checkpoint-disable)
(message "Undo end-point ignored!")))
@@ -351,6 +389,7 @@ Optional argument ARG the number of steps to undo."
'evil
'
(progn
+ (evil-declare-not-repeat 'undo-fu-disable-checkpoint)
(evil-declare-not-repeat 'undo-fu-only-undo)
(evil-declare-not-repeat 'undo-fu-only-redo)
(evil-declare-not-repeat 'undo-fu-only-redo-all)))
- [nongnu] elpa/undo-fu 85fa6556e9 04/82: Add evil-mode key binding example, (continued)
- [nongnu] elpa/undo-fu 85fa6556e9 04/82: Add evil-mode key binding example, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu c20637ffe3 11/82: Fix typo, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 9cfc95948a 19/82: Cleanup: remove unnecessary calculation, auto-load redo-all, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu f8f416c0d4 25/82: readme: capitalize 'Emacs', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu f53b3e3963 26/82: Use eval-after-load instead of with-eval-after-load for Emacs 24.3, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 5c9aadad4b 27/82: Support using undo-fu-only-redo after regular undo/undo-only, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 6e8095c449 29/82: Suppress compiler warnings about evil functions, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 7d600ab8f2 30/82: Fix 'success' assignment (internal variable), ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 3c366ef52a 33/82: Add '.elisp-autofmt' to enable auto-formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 4d635722a3 34/82: readme: minor improvements to wording, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 88c4086e12 43/82: Add 'undo-fu-ignore-keyboard-quit' & 'undo-fu-disable-checkpoint',
ELPA Syncer <=
- [nongnu] elpa/undo-fu 2b1e53285a 55/82: Fix checkpoint initialization with undo data from undo-fu-session, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu a651bb3035 57/82: Complete docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 46de023b5f 58/82: Use logic back-ported from emacs-28 'undo-redo', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 8b00b16fa8 46/82: Non-destructive commands no longer break the undo-chain, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 6c31b8e565 59/82: Protect undo-fu from aggressive-indent, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 7cbc3f852b 63/82: readme: move details into own top-level heading, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu e0ad06b5ef 64/82: Cleanup: formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 1d60424680 50/82: Raise error when using undo-fu commands when undo has been disabled, ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 06b52a11d9 69/82: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/undo-fu 3ae95e60f6 65/82: Update readme example, remove call to disable undo-tree, ELPA Syncer, 2022/07/07