[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree c00c1fe 031/195: Add new undo-tree-kill-visua
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree c00c1fe 031/195: Add new undo-tree-kill-visualizer to before-change-functions hook |
Date: |
Sat, 28 Nov 2020 13:41:14 -0500 (EST) |
branch: externals/undo-tree
commit c00c1feeddb46e962dc9cf00af51ddb34c9768d3
Author: tsc25 <tsc25@cantab.net>
Commit: tsc25 <tsc25@cantab.net>
Add new undo-tree-kill-visualizer to before-change-functions hook
to kill visualizer as soon as original buffer is modified.
---
undo-tree.el | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index de0f78d..2479447 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -513,6 +513,7 @@ in visualizer.")
+
;;; =================================================================
;;; Setup default keymaps
@@ -687,6 +688,7 @@ in visualizer.")
+
;;; =====================================================================
;;; Basic undo-tree data structure functions
@@ -952,6 +954,7 @@ which is defined in the `warnings' library.\n")
+
;;; =====================================================================
;;; Utility functions for handling `buffer-undo-list'
@@ -1022,6 +1025,7 @@ which is defined in the `warnings' library.\n")
+
;;; =====================================================================
;;; Undo-tree commands
@@ -1050,7 +1054,6 @@ Within the undo-tree visualizer, the following keys are
available:
(unless undo-tree-mode (setq buffer-undo-list nil)))
-
(defun turn-on-undo-tree-mode ()
"Enable undo-tree-mode."
(undo-tree-mode 1))
@@ -1226,6 +1229,8 @@ using `undo-tree-redo'."
(setq buffer-undo-tree (make-undo-tree)))
;; transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'
(undo-list-transfer-to-tree)
+ ;; add hook to kill visualizer buffer if original buffer is changed
+ (add-hook 'before-change-functions 'undo-tree-kill-visualizer nil t)
;; prepare *undo-tree* buffer, then draw tree in it
(let ((undo-tree buffer-undo-tree)
(buff (current-buffer)))
@@ -1239,6 +1244,17 @@ using `undo-tree-redo'."
(setq buffer-read-only t)))
+(defun undo-tree-kill-visualizer (&rest dummy)
+ ;; Kill visualizer. Added to `before-change-functions' hook of original
+ ;; buffer when visualizer is invoked.
+ (unwind-protect
+ (save-excursion
+ (set-buffer " *undo-tree*")
+ (undo-tree-visualizer-quit))
+ ;; remove hook now that visualizer has been killed
+ (remove-hook 'before-change-functions 'undo-tree-kill-visualizer t)))
+
+
(defun undo-tree-draw-tree (undo-tree)
;; Draw UNDO-TREE in current buffer.
@@ -1276,7 +1292,6 @@ using `undo-tree-redo'."
(undo-tree-draw-node (undo-tree-current undo-tree) 'current)))
-
(defun undo-tree-highlight-active-branch (node)
;; Draw highlighted active branch below NODE in current buffer.
(let ((stack (list node)))
@@ -1293,7 +1308,6 @@ using `undo-tree-redo'."
(setq stack (append stack node)))))
-
(defun undo-tree-draw-node (node &optional current)
;; Highlight NODE as current node.
(goto-char (undo-tree-node-marker node))
@@ -1312,7 +1326,6 @@ using `undo-tree-redo'."
(put-text-property (point) (1+ (point)) 'undo-tree-node node)))
-
(defun undo-tree-draw-subtree (node &optional active-branch)
;; Draw subtree rooted at NODE. The subtree will start from point.
;; If ACTIVE-BRANCH is non-nil, just draw active branch below NODE.
@@ -1507,6 +1520,7 @@ using `undo-tree-redo'."
+
;;; =====================================================================
;;; Visualizer mode commands
- [elpa] externals/undo-tree 711dd60 003/195: Implemented undo-tree data structure and undo command., (continued)
- [elpa] externals/undo-tree 711dd60 003/195: Implemented undo-tree data structure and undo command., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b15904c 023/195: Update timestamps when nodes are visited by undo/redo., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 21d3c89 004/195: Implemented redo command., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f87f815 024/195: Added utility functions for use in discarding undo history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree dcabd4f 002/195: Added .gitignore to ignore byte-compiled elisp files., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f370170 019/195: Rewrote undo-tree-draw-tree and undo-tree-draw-subtree, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 73c1d04 007/195: Lumped visualizer data into single undo-tree node entry,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4dd6905 028/195: Discard marker adjustment undo entries., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 09fb370 027/195: Added lighter to undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b074b86 029/195: Updated commentary, and switched to GPLv3., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c00c1fe 031/195: Add new undo-tree-kill-visualizer to before-change-functions hook,
Stefan Monnier <=
- [elpa] externals/undo-tree aaa4c6d 012/195: Don't create new marker each time we draw a node., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 159c9b4 005/195: Implemented undo-tree branch switching., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0bbfa5c 026/195: Tweaked commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 86fb076 034/195: Fixed keybindings., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 948386b 035/195: Modified undo-tree-visualizer-active-branch-face, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bca52bf 042/195: Added undo-tree-mode-lighter customization option, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 50ccefd 043/195: Fixed bug in undo-tree-discard-node., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree fd3fc5c 046/195: Pass null argument to kill-buffer call in undo-tree-visualizer-quit,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 45751ef 050/195: Fixed bug in undo-tree-switch-branch., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f454e88 001/195: Started project to add vim-like undo tree handling to emacs., Stefan Monnier, 2020/11/28