emacs-elpa-diffs
[Top][All Lists]
Advanced

[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)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]