[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree b8652b4 180/195: Null undo-tree-limit attemps
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree b8652b4 180/195: Null undo-tree-limit attemps to preserve all undo history. |
Date: |
Sat, 28 Nov 2020 13:41:48 -0500 (EST) |
branch: externals/undo-tree
commit b8652b43045d7e511cd04fab64881eb26c04977c
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Null undo-tree-limit attemps to preserve all undo history.
---
undo-tree.el | 43 ++++++++++++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index b1c6612..71a4ee0 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -874,13 +874,25 @@
"Tree undo/redo."
:group 'undo)
+
(defcustom undo-tree-limit 80000000
"Value of `undo-limit' used in `undo-tree-mode'.
If `undo-limit' is larger than `undo-tree-limit', the larger of
-the two values will be used."
+the two values will be used.
+
+Setting this to nil prevents `undo-tree-mode' ever discarding
+undo history. (As far as possible. In principle, it is still
+possible for Emacs to discard undo history behind
+`undo-tree-mode's back.)
+
+USE THIS SETTING AT YOUR OWN RISK! Emacs may crash if undo
+history exceeds Emacs' available memory. This is particularly
+risky if `undo-tree-auto-save-history' is enabled, as in that
+case undo history is preserved even between Emacs sessions."
:group 'undo-tree
- :type 'integer)
+ :type '(choice integer (const nil)))
+
(defcustom undo-tree-strong-limit 120000000
"Value of `undo-strong-limit' used in `undo-tree-mode'.
@@ -890,6 +902,7 @@ the larger of the two values will be used."
:group 'undo-tree
:type 'integer)
+
(defcustom undo-tree-outer-limit 360000000
"Value of `undo-outer-limit' used in `undo-tree-mode'.
@@ -2690,6 +2703,8 @@ of either NODE itself or some node above it in the tree."
;;; =====================================================================
;;; Undo-tree commands
+(defvar undo-tree-timer nil)
+
;;;###autoload
(define-minor-mode undo-tree-mode
"Toggle undo-tree mode.
@@ -2713,21 +2728,31 @@ Within the undo-tree visualizer, the following keys are
available:
undo-tree-mode-lighter ; lighter
undo-tree-map ; keymap
- ;; if disabling `undo-tree-mode', rebuild `buffer-undo-list' from tree so
- ;; Emacs undo can work
(cond
- (undo-tree-mode
+ (undo-tree-mode ; enabling `undo-tree-mode'
(set (make-local-variable 'undo-limit)
- (max undo-limit undo-tree-limit))
+ (if undo-tree-limit
+ (max undo-limit undo-tree-limit)
+ most-positive-fixnum))
(set (make-local-variable 'undo-strong-limit)
- (max undo-strong-limit undo-tree-strong-limit))
+ (if undo-tree-limit
+ (max undo-strong-limit undo-tree-strong-limit)
+ most-positive-fixnum))
(set (make-local-variable 'undo-outer-limit)
- (max undo-outer-limit undo-tree-outer-limit))
+ (if undo-tree-limit
+ (max undo-outer-limit undo-tree-outer-limit)
+ most-positive-fixnum))
+ (when (null undo-tree-limit)
+ (setq undo-tree-timer
+ (run-with-idle-timer 5 'repeat #'undo-list-transfer-to-tree)))
(add-hook 'post-gc-hook #'undo-tree-post-gc nil))
- (t
+
+ (t ; disabling `undo-tree-mode'
+ ;; rebuild `buffer-undo-list' from tree so Emacs undo can work
(undo-list-rebuild-from-tree)
(setq buffer-undo-tree nil)
(remove-hook 'post-gc-hook #'undo-tree-post-gc 'local)
+ (when (timerp undo-tree-timer) (cancel-timer undo-tree-timer))
(kill-local-variable 'undo-limit)
(kill-local-variable 'undo-strong-limit)
(kill-local-variable 'undo-outer-limit))))
- [elpa] externals/undo-tree bc9d095 156/195: Clear undo-tree-visualizer-needs-extending-[up|down] before drawing tree., (continued)
- [elpa] externals/undo-tree bc9d095 156/195: Clear undo-tree-visualizer-needs-extending-[up|down] before drawing tree., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b35a6af 160/195: Bump copyright year and version number., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree a3e81b6 161/195: Fix bug that caused undo-tree to hang when undoing in region (bug#16377)., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 2947d7c 169/195: Add hooks to transform/discard undo elements on saving/loading., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c3d04ea 165/195: Change obsolete subtract-time -> time-subtract., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree af99ee3 166/195: Uncoditionally clear visualizer data before writing to file., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f6471ef 173/195: Simplify undo-list-byte-size., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ea165ed 174/195: Refactor undo-list-transfer-to-tree to not act directly on buffer-undo-list., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8842bb5 176/195: More undo-tree GC corruption mitigations., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f6f557c 178/195: Fix various bugs in undo history loading/saving., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b8652b4 180/195: Null undo-tree-limit attemps to preserve all undo history.,
Stefan Monnier <=
- [elpa] externals/undo-tree f0a6192 184/195: Proper fix to copy-undo-tree by writing bespoke copier., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 3090c4f 185/195: Temporarily increase max-lisp-eval-depth and max-specpdl-size when copying undo-trees., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8cf384f 187/195: Redraw visualizer when history-discarding invalidates it., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d79fab9 193/195: Switch from cl to cl-lib., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bd65bb0 192/195: Fix hook function issue in Emacs 27., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e01a3e7 191/195: Fix some byte-compilation warnings., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 17454bd 084/195: Improved undo-tree-switch-branch behaviour., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f16ab5f 067/195: Trivial fix in Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e8215a7 078/195: Minor typo fixes in comments., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8697a0b 077/195: Clear registers referring to nodes being discarded from undo history., Stefan Monnier, 2020/11/28