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

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

[elpa] externals/undo-tree 98170c6 075/195: Added additional check to mo


From: Stefan Monnier
Subject: [elpa] externals/undo-tree 98170c6 075/195: Added additional check to more reliably identify marker undo elements.
Date: Sat, 28 Nov 2020 13:41:25 -0500 (EST)

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

    Added additional check to more reliably identify marker undo elements.
    
    Recent bzr Emacs builds seem to add a new (and currently undocumented) 
buffer
    modification undo element format: (t . -1) which appears to be used for the
    initial modification entry for new files. This was getting incorrectly
    identified as a marker undo entry, and deleted by undo-list-clean-GCd-elts,
    preventing the buffer modification state from being restored correctly on
    undoing.
    
    The additional check in undo-list-GCd-marker-elt-p, on the symbol name in 
the
    car of the undo element, fixes this.
---
 undo-tree.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/undo-tree.el b/undo-tree.el
index 869e567..4a3b780 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -4,7 +4,7 @@
 ;; Copyright (C) 2009-2011 Toby Cubitt
 
 ;; Author: Toby Cubitt <toby-undo-tree@dr-qubit.org>
-;; Version: 0.3.1
+;; Version: 0.3.2
 ;; Keywords: convenience, files, undo, redo, history, tree
 ;; URL: http://www.dr-qubit.org/emacs.php
 ;; Git Repository: http://www.dr-qubit.org/git/undo-tree.git
@@ -605,6 +605,10 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.3.2
+;; * added additional check in `undo-list-GCd-marker-elt-p' to guard against
+;;   undo elements being mis-identified as marker elements.
+;;
 ;; Version 0.3.1
 ;; * use `get-buffer-create' when creating the visualizer buffer in
 ;;   `undo-tree-visualize', to fix bug caused by `global-undo-tree-mode' being
@@ -1288,7 +1292,17 @@ Comparison is done with `eq'."
   `(markerp (car-safe ,elt)))
 
 (defmacro undo-list-GCd-marker-elt-p (elt)
-  `(and (symbolp (car-safe ,elt)) (numberp (cdr-safe ,elt))))
+  ;; Return t if ELT is a marker element whose marker has been moved to the
+  ;; object-pool, so may potentially have been garbage-collected.
+  ;; Note: Valid marker undo elements should be uniquely identified as cons
+  ;; cells with a symbol in the car (replacing the marker), and a number in
+  ;; the cdr. However, to guard against future changes to undo element
+  ;; formats, we perform an additional redundant check on the symbol name.
+  `(and (symbolp (car-safe ,elt))
+       (let ((str (symbol-name (car ,elt))))
+         (and (> (length str) 12)
+              (string= (substring str 0 12) "undo-tree-id")))
+       (numberp (cdr-safe ,elt))))
 
 
 (defun undo-tree-move-GC-elts-to-pool (elt)



reply via email to

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