[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree f566beb 106/195: Add customization option all
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree f566beb 106/195: Add customization option allowing timestamps to be displayed by default |
Date: |
Sat, 28 Nov 2020 13:41:32 -0500 (EST) |
branch: externals/undo-tree
commit f566beb58b3585f9feefe6da4ab32de2780f655d
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Add customization option allowing timestamps to be displayed by default
by making undo-tree-visualizer-timestamps into a defcustom.
---
undo-tree.el | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 35033a9..cefff36 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -650,6 +650,8 @@
;; * clear visualizer data / kill visualizer in `undo-tree-save-history'
;; before saving history to file, otherwise markers in visualizer meta-data
;; cause read errors in `undo-tree-load-history'
+;; * make `undo-tree-visualizer-timestamps' into defcustom, to allow
+;; timestamps to be displayed by default
;;
;; Version 0.4
;; * implemented persistent history storage: `undo-tree-save-history' and
@@ -949,6 +951,18 @@ Otherwise, display absolute times."
:type 'boolean)
+(defcustom undo-tree-visualizer-timestamps nil
+ "When non-nil, display time-stamps by default
+in undo-tree visualizer.
+
+\\<undo-tree-visualizer-map>You can always toggle time-stamps on and off \
+using \\[undo-tree-visualizer-toggle-timestamps], regardless of the
+setting of this variable."
+ :group 'undo-tree
+ :type 'boolean)
+(make-variable-buffer-local 'undo-tree-visualizer-timestamps)
+
+
(defcustom undo-tree-visualizer-diff nil
"When non-nil, display diff by default in undo-tree visualizer.
@@ -1007,21 +1021,25 @@ in visualizer."
"Parent buffer in visualizer.")
(make-variable-buffer-local 'undo-tree-visualizer-parent-buffer)
-(defvar undo-tree-visualizer-timestamps nil
- "Non-nil when visualizer is displaying time-stamps.")
-(make-variable-buffer-local 'undo-tree-visualizer-timestamps)
-
-(defvar undo-tree-visualizer-spacing 3
- "Horizontal spacing needed for drawing undo-tree in visualizer.")
+;; stores current horizontal spacing needed for drawing undo-tree
+(defvar undo-tree-visualizer-spacing nil)
(make-variable-buffer-local 'undo-tree-visualizer-spacing)
-(defconst undo-tree-visualizer-buffer-name " *undo-tree*")
-(defconst undo-tree-diff-buffer-name "*undo-tree Diff*")
+;; calculate horizontal spacing required for drawing undo-tree with current
+;; settings
+(defsubst undo-tree-visualizer-calculate-spacing ()
+ (if undo-tree-visualizer-timestamps
+ (if undo-tree-visualizer-relative-timestamps 9 13)
+ 3))
;; dynamically bound to t when undoing from visualizer, to inhibit
;; `undo-tree-kill-visualizer' hook function in parent buffer
(defvar undo-tree-inhibit-kill-visualizer nil)
+
+(defconst undo-tree-visualizer-buffer-name " *undo-tree*")
+(defconst undo-tree-diff-buffer-name "*undo-tree Diff*")
+
;; prevent debugger being called on "No further redo information"
(add-to-list 'debug-ignored-errors "^No further redo information")
@@ -3007,6 +3025,8 @@ signaling an error if file is not found."
(get-buffer-create undo-tree-visualizer-buffer-name))
(setq undo-tree-visualizer-parent-buffer buff)
(setq buffer-undo-tree undo-tree)
+ (setq undo-tree-visualizer-spacing
+ (undo-tree-visualizer-calculate-spacing))
(when undo-tree-visualizer-diff (undo-tree-visualizer-show-diff))
(undo-tree-visualizer-mode)
(let ((inhibit-read-only t)) (undo-tree-draw-tree undo-tree))))
@@ -3502,12 +3522,8 @@ at mouse event POS."
(defun undo-tree-visualizer-toggle-timestamps ()
"Toggle display of time-stamps."
(interactive)
- (setq undo-tree-visualizer-spacing
- (if (setq undo-tree-visualizer-timestamps
- (not undo-tree-visualizer-timestamps))
- ;; need sufficient space if displaying timestamps
- (if undo-tree-visualizer-relative-timestamps 9 13)
- (default-value 'undo-tree-visualizer-spacing)))
+ (setq undo-tree-visualizer-timestamps (not undo-tree-visualizer-timestamps))
+ (setq undo-tree-visualizer-spacing (undo-tree-visualizer-calculate-spacing))
;; redraw tree
(let ((inhibit-read-only t)) (undo-tree-draw-tree buffer-undo-tree)))
- [elpa] externals/undo-tree f3e7324 090/195: Use undo-tree-inhibit-kill-visualizer to inhibit undo-tree-kill-visualizer., (continued)
- [elpa] externals/undo-tree f3e7324 090/195: Use undo-tree-inhibit-kill-visualizer to inhibit undo-tree-kill-visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bb92692 093/195: Don't override diff-switches customization option in visualizer diff display., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree a220a42 097/195: Added registerv-make and registerv-data compatibility macros in Emacs <= 23., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 95599db 100/195: Fixed bug in visualizer selection mode when timestamps are displayed., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 81f1417 098/195: Added diff-no-select and diff-file-local-copy compatibility hacks, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree aa7202c 103/195: Fix the way keymaps are defined., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e69adb3 109/195: Remove now unnecessary compatibility hack for called-interactively-p., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 00ffbb6 121/195: Bump version number below which we warn against enabling persistent storage., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5df6374 128/195: Switch to lexical binding., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 9b55464 126/195: Make undo history filename match docs., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f566beb 106/195: Add customization option allowing timestamps to be displayed by default,
Stefan Monnier <=
- [elpa] externals/undo-tree f3e0d93 119/195: Remove ChangeLog section from package headers., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 36b341b 112/195: Cope better if undo boundary before undo-tree-canary is missing., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 98dbabd 125/195: Implement visualizer commands to redo/undo to branch/register., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 85efe23 116/195: Ensure auto-compression-mode is enabled when reading undo history file., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 181e84b 124/195: Minor bug fix and tweak to visualizer register display., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0ba2d37 122/195: Fix bug in undo-tree-clear-visualizer-data., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 443d74c 111/195: Avoid triggering error when saving undo history when there's nothing to save., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5d06288 130/195: Implement lazy undo-tree drawing in visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4c14173 115/195: Fix undo history auto-saving., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e352286 131/195: Fix incompatiblity with newer high-resolution timestamps., Stefan Monnier, 2020/11/28