[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 8cf384f 187/195: Redraw visualizer when histo
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 8cf384f 187/195: Redraw visualizer when history-discarding invalidates it. |
Date: |
Sat, 28 Nov 2020 13:41:50 -0500 (EST) |
branch: externals/undo-tree
commit 8cf384fc212e7767b89149f22ff7941b2e3d8d55
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Redraw visualizer when history-discarding invalidates it.
---
undo-tree.el | 69 +++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 43 insertions(+), 26 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 4339f0e..de15a3b 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -2054,12 +2054,14 @@ set by `undo-limit', `undo-strong-limit' and
`undo-outer-limit'."
(let ((node (if (> (length (undo-tree-node-next
(undo-tree-root buffer-undo-tree))) 1)
(undo-tree-oldest-leaf (undo-tree-root buffer-undo-tree))
- (undo-tree-root buffer-undo-tree))))
+ (undo-tree-root buffer-undo-tree)))
+ discarded)
;; discard nodes until memory use is within `undo-strong-limit'
(while (and node
(> (undo-tree-size buffer-undo-tree) undo-strong-limit))
- (setq node (undo-tree-discard-node node)))
+ (setq node (undo-tree-discard-node node)
+ discarded t))
;; discard nodes until next node to discard would bring memory use
;; within `undo-limit'
@@ -2087,8 +2089,11 @@ set by `undo-limit', `undo-strong-limit' and
`undo-outer-limit'."
(undo-list-byte-size (undo-tree-node-redo node)))
))
undo-limit))
- (setq node (undo-tree-discard-node node)))
- (message "Undo history discarded by undo-tree (see `undo-tree-limit')")
+ (setq node (undo-tree-discard-node node)
+ discarded t))
+
+ (when discarded
+ (message "Undo history discarded by undo-tree (see `undo-tree-limit')"))
;; if we're still over the `undo-outer-limit', discard entire history
(when (> (undo-tree-size buffer-undo-tree) undo-outer-limit)
@@ -2123,6 +2128,17 @@ You can disable the popping up of this buffer by adding
the entry
which is defined in the `warnings' library.\n")
:warning)
(setq buffer-undo-tree nil)))
+
+ ;; if currently displaying the visualizer, redraw it
+ (when (and buffer-undo-tree
+ discarded
+ (or (eq major-mode 'undo-tree-visualizer-mode)
+ undo-tree-visualizer-parent-buffer
+ (get-buffer undo-tree-visualizer-buffer-name)))
+ (let ((undo-tree buffer-undo-tree))
+ (with-current-buffer undo-tree-visualizer-buffer-name
+ (undo-tree-draw-tree undo-tree)
+ (when undo-tree-visualizer-diff
(undo-tree-visualizer-update-diff)))))
)))
@@ -3448,7 +3464,8 @@ Note this will overwrite any existing undo history."
(defun undo-tree-draw-tree (undo-tree)
;; Draw undo-tree in current buffer starting from NODE (or root if nil).
- (let ((node (if undo-tree-visualizer-lazy-drawing
+ (let ((inhibit-read-only t)
+ (node (if undo-tree-visualizer-lazy-drawing
(undo-tree-current undo-tree)
(undo-tree-root undo-tree))))
(erase-buffer)
@@ -4068,10 +4085,6 @@ Within the undo-tree visualizer, the following keys are
available:
(user-error "Undo-tree mode not enabled in buffer"))
(let ((old (undo-tree-current buffer-undo-tree))
current)
- ;; unhighlight old current node
- (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face)
- (inhibit-read-only t))
- (undo-tree-draw-node old))
;; undo in parent buffer
(switch-to-buffer-other-window undo-tree-visualizer-parent-buffer)
(deactivate-mark)
@@ -4079,6 +4092,10 @@ Within the undo-tree visualizer, the following keys are
available:
(let ((undo-tree-inhibit-kill-visualizer t)) (undo-tree-undo-1 arg))
(setq current (undo-tree-current buffer-undo-tree))
(switch-to-buffer-other-window undo-tree-visualizer-buffer-name)
+ ;; unhighlight old current node
+ (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face)
+ (inhibit-read-only t))
+ (undo-tree-draw-node old))
;; when using lazy drawing, extend tree upwards as required
(when undo-tree-visualizer-lazy-drawing
(undo-tree-expand-up old current))
@@ -4095,10 +4112,6 @@ Within the undo-tree visualizer, the following keys are
available:
(user-error "Undo-tree mode not enabled in buffer"))
(let ((old (undo-tree-current buffer-undo-tree))
current)
- ;; unhighlight old current node
- (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face)
- (inhibit-read-only t))
- (undo-tree-draw-node (undo-tree-current buffer-undo-tree)))
;; redo in parent buffer
(switch-to-buffer-other-window undo-tree-visualizer-parent-buffer)
(deactivate-mark)
@@ -4106,6 +4119,10 @@ Within the undo-tree visualizer, the following keys are
available:
(let ((undo-tree-inhibit-kill-visualizer t)) (undo-tree-redo-1 arg))
(setq current (undo-tree-current buffer-undo-tree))
(switch-to-buffer-other-window undo-tree-visualizer-buffer-name)
+ ;; unhighlight old current node
+ (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face)
+ (inhibit-read-only t))
+ (undo-tree-draw-node old))
;; when using lazy drawing, extend tree downwards as required
(when undo-tree-visualizer-lazy-drawing
(undo-tree-expand-down old current))
@@ -4129,19 +4146,19 @@ using `undo-tree-redo' or `undo-tree-visualizer-redo'."
(undo-tree-highlight-active-branch (undo-tree-current buffer-undo-tree)))
;; increment branch
(let ((branch (undo-tree-node-branch (undo-tree-current buffer-undo-tree))))
- (setf (undo-tree-node-branch (undo-tree-current buffer-undo-tree))
- (cond
- ((>= (+ branch arg) (undo-tree-num-branches))
- (1- (undo-tree-num-branches)))
- ((<= (+ branch arg) 0) 0)
- (t (+ branch arg))))
- (let ((inhibit-read-only t))
- ;; highlight new active branch below current node
- (goto-char (undo-tree-node-marker (undo-tree-current buffer-undo-tree)))
- (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face))
- (undo-tree-highlight-active-branch (undo-tree-current buffer-undo-tree)))
- ;; re-highlight current node
- (undo-tree-draw-node (undo-tree-current buffer-undo-tree) 'current))))
+ (setf (undo-tree-node-branch (undo-tree-current buffer-undo-tree))
+ (cond
+ ((>= (+ branch arg) (undo-tree-num-branches))
+ (1- (undo-tree-num-branches)))
+ ((<= (+ branch arg) 0) 0)
+ (t (+ branch arg))))
+ (let ((inhibit-read-only t))
+ ;; highlight new active branch below current node
+ (goto-char (undo-tree-node-marker (undo-tree-current buffer-undo-tree)))
+ (let ((undo-tree-insert-face 'undo-tree-visualizer-active-branch-face))
+ (undo-tree-highlight-active-branch (undo-tree-current
buffer-undo-tree)))
+ ;; re-highlight current node
+ (undo-tree-draw-node (undo-tree-current buffer-undo-tree) 'current))))
(defun undo-tree-visualize-switch-branch-left (arg)
- [elpa] externals/undo-tree 2947d7c 169/195: Add hooks to transform/discard undo elements on saving/loading., (continued)
- [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, 2020/11/28
- [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 <=
- [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
- [elpa] externals/undo-tree f956d55 074/195: Added autoload cookies, and other tweaks to prepare for ELPA packaging., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4e558f8 088/195: Make various interactive commands signal an error if buffer is read-only., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e001bd5 091/195: Implemented diff display in visualizer., Stefan Monnier, 2020/11/28