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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/undo-tree e352286 131/195: Fix incompatiblity with newe


From: Stefan Monnier
Subject: [elpa] externals/undo-tree e352286 131/195: Fix incompatiblity with newer high-resolution timestamps.
Date: Sat, 28 Nov 2020 13:41:37 -0500 (EST)

branch: externals/undo-tree
commit e352286c4107bb3303fa0dc9b6db71c8b151b7cc
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>

    Fix incompatiblity with newer high-resolution timestamps.
---
 undo-tree.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/undo-tree.el b/undo-tree.el
index e648bee..1ae7e70 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -2037,11 +2037,10 @@ which is defined in the `warnings' library.\n")
    (undo-tree-root tree)))
 
 
-(defun undo-tree-node-saved-buffer-p (node &optional mtime)
-  ;; Return non-nil if NODE corresponds to a saved buffer state (not
-  ;; necessarily the current saved state). If a file modification time MTIME
-  ;; is specified, also check that the changeset's modification time
-  ;; corresponds to MTIME.
+(defun undo-tree-node-unmodified-p (node &optional mtime)
+  ;; Return non-nil if NODE corresponds to a buffer state that once upon a
+  ;; time was unmodified. If a file modification time MTIME is specified,
+  ;; return non-nil if the buffer state really is unmodified.
   (let (changeset ntime)
     (setq changeset
          (or (undo-tree-node-redo node)
@@ -2054,8 +2053,12 @@ which is defined in the `warnings' library.\n")
                         (throw 'found (cdr elt)))))))
     (and ntime
         (or (null mtime)
-            (and (= (car ntime)  (car mtime))
-                 (= (cdr ntime) (cadr mtime)))))))
+            ;; high-precision timestamps
+            (if (listp (cdr ntime))
+                (equal ntime mtime)
+              ;; old-style timestamps
+              (and (= (car ntime) (car mtime))
+                   (= (cdr ntime) (cadr mtime))))))))
 
 
 
@@ -3387,9 +3390,10 @@ signaling an error if file is not found."
                                              undo-tree-insert-face)
                                         (list undo-tree-insert-face))))
         (register (undo-tree-node-register node))
-        (unmodified (and undo-tree-visualizer-parent-mtime
-                         (undo-tree-node-saved-buffer-p
-                          node undo-tree-visualizer-parent-mtime)))
+        (unmodified (if undo-tree-visualizer-parent-mtime
+                        (undo-tree-node-unmodified-p
+                         node undo-tree-visualizer-parent-mtime)
+                      (undo-tree-node-unmodified-p node)))
        node-string)
     ;; check node's register (if any) still stores appropriate undo-tree state
     (unless (and register
@@ -3940,7 +3944,7 @@ spcified `saved', and a negative prefix argument specifies
                              (eq current (undo-tree-register-data-node r)))
                         ;; saved state
                         (and (or (null x) (eq x 'saved))
-                             (undo-tree-node-saved-buffer-p current))
+                             (undo-tree-node-unmodified-p current))
                         ))))))
 
 
@@ -3975,7 +3979,7 @@ a negative prefix argument specifies `register'."
                              (eq current (undo-tree-register-data-node r)))
                         ;; saved state
                         (and (or (null x) (eq x 'saved))
-                             (undo-tree-node-saved-buffer-p current))
+                             (undo-tree-node-unmodified-p current))
                         ))))))
 
 



reply via email to

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