[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 133b439 148/195: Set protected-local property
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 133b439 148/195: Set protected-local property on various visualizer variables. |
Date: |
Sat, 28 Nov 2020 13:41:41 -0500 (EST) |
branch: externals/undo-tree
commit 133b4399ce278baaff7ef81d792db1ceb768ccfa
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Set protected-local property on various visualizer variables.
Prevents them being cleared by undo-tree-visualizer-mode, so can now set
them
before calling it from undo-tree-visualize, making
undo-tree-visualizer-mode-hook more useful. E.g. can add
undo-tree-visualizer-selection-mode to this hook to enable selection-mode by
default.
---
undo-tree.el | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 353d786..14aa642 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -845,8 +845,8 @@
(defvar buffer-undo-tree nil
"Tree of undo entries in current buffer.")
-(make-variable-buffer-local 'buffer-undo-tree)
(put 'buffer-undo-tree 'permanent-local t)
+(make-variable-buffer-local 'buffer-undo-tree)
(defgroup undo-tree nil
@@ -1015,14 +1015,17 @@ in visualizer."
(defvar undo-tree-visualizer-parent-buffer nil
"Parent buffer in visualizer.")
+(put 'undo-tree-visualizer-parent-buffer 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-parent-buffer)
;; stores modification time of parent buffer's file, if any
(defvar undo-tree-visualizer-parent-mtime nil)
+(put 'undo-tree-visualizer-parent-mtime 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-parent-mtime)
;; stores current horizontal spacing needed for drawing undo-tree
(defvar undo-tree-visualizer-spacing nil)
+(put 'undo-tree-visualizer-spacing 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-spacing)
;; calculate horizontal spacing required for drawing tree with current
@@ -1034,16 +1037,20 @@ in visualizer."
;; holds node that was current when visualizer was invoked
(defvar undo-tree-visualizer-initial-node nil)
+(put 'undo-tree-visualizer-initial-node 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-initial-node)
;; holds currently selected node in visualizer selection mode
(defvar undo-tree-visualizer-selected-node nil)
+(put 'undo-tree-visualizer-selected-node 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-selected)
;; used to store nodes at edge of currently drawn portion of tree
(defvar undo-tree-visualizer-needs-extending-down nil)
+(put 'undo-tree-visualizer-needs-extending-down 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-needs-extending-down)
(defvar undo-tree-visualizer-needs-extending-up nil)
+(put 'undo-tree-visualizer-needs-extending-up 'permanent-local t)
(make-variable-buffer-local 'undo-tree-visualizer-needs-extending-up)
;; dynamically bound to t when undoing from visualizer, to inhibit
@@ -3079,12 +3086,12 @@ signaling an error if file is not found."
(setq hash (read (current-buffer)))
(error
(kill-buffer nil)
- (funcall (if noerror 'message 'error)
+ (funcall (if noerror 'message 'user-error)
"Error reading undo-tree history from \"%s\"" filename)
(throw 'load-error nil)))
(unless (string= (sha1 buff) hash)
(kill-buffer nil)
- (funcall (if noerror 'message 'error)
+ (funcall (if noerror 'message 'user-error)
"Buffer has been modified; could not load undo-tree
history")
(throw 'load-error nil))
(condition-case nil
@@ -3138,17 +3145,19 @@ signaling an error if file is not found."
(display-buffer-mark-dedicated 'soft))
(switch-to-buffer-other-window
(get-buffer-create undo-tree-visualizer-buffer-name))
- (undo-tree-visualizer-mode)
(setq undo-tree-visualizer-parent-buffer buff)
(setq undo-tree-visualizer-parent-mtime
(and (buffer-file-name buff)
(nth 5 (file-attributes (buffer-file-name buff)))))
- (setq buffer-undo-tree undo-tree)
(setq undo-tree-visualizer-initial-node (undo-tree-current undo-tree))
(setq undo-tree-visualizer-spacing
(undo-tree-visualizer-calculate-spacing))
(make-local-variable 'undo-tree-visualizer-timestamps)
(make-local-variable 'undo-tree-visualizer-diff)
+ (setq buffer-undo-tree undo-tree)
+ (undo-tree-visualizer-mode)
+ ;; FIXME; don't know why `undo-tree-visualizer-mode' clears this
+ (setq buffer-undo-tree undo-tree)
(set (make-local-variable 'undo-tree-visualizer-lazy-drawing)
(or (eq undo-tree-visualizer-lazy-drawing t)
(and (numberp undo-tree-visualizer-lazy-drawing)
@@ -3161,10 +3170,10 @@ signaling an error if file is not found."
(defun undo-tree-kill-visualizer (&rest _dummy)
;; Kill visualizer. Added to `before-change-functions' hook of original
;; buffer when visualizer is invoked.
- (unless undo-tree-inhibit-kill-visualizer
- (unwind-protect
- (with-current-buffer undo-tree-visualizer-buffer-name
- (undo-tree-visualizer-quit)))))
+ (unless (or undo-tree-inhibit-kill-visualizer
+ (null (get-buffer undo-tree-visualizer-buffer-name)))
+ (with-current-buffer undo-tree-visualizer-buffer-name
+ (undo-tree-visualizer-quit))))
@@ -3777,8 +3786,7 @@ Within the undo-tree visualizer, the following keys are
available:
:abbrev-table nil
(setq truncate-lines t)
(setq cursor-type nil)
- (setq undo-tree-visualizer-selected-node nil)
- (when undo-tree-visualizer-diff (undo-tree-visualizer-update-diff)))
+ (setq undo-tree-visualizer-selected-node nil))
- [elpa] externals/undo-tree 18754c1 114/195: Use with-temp-buffer instead of with-temp-file when saving undo history., (continued)
- [elpa] externals/undo-tree 18754c1 114/195: Use with-temp-buffer instead of with-temp-file when saving undo history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c9f78c3 137/195: Use new user-error instead of error for expected undo errors., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 1114679 135/195: Fix bugs in binding of undo-tree-insert-face., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5d19d4e 155/195: Bump version number and copyright year., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ffb346a 157/195: Install undo-tree undo/redo Edit menu bar items., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 19baf49 158/195: Fix undo/redo-in-region tree diagrams in Commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 22d6c01 153/195: Fix bug that cleared tree when enabling undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 46639dd 154/195: Tweak undo history file names to match Emacs backup file names., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree fba51e6 146/195: Add undo-tree-visualizer[-mouse]-select functions to select node at pos or click., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 43663f6 159/195: Fix bug in menu entries that triggered error on null buffer-undo-tree., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 133b439 148/195: Set protected-local property on various visualizer variables.,
Stefan Monnier <=
- [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