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

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

[elpa] externals/undo-tree d5a6148 120/195: Don't try to auto-save undo


From: Stefan Monnier
Subject: [elpa] externals/undo-tree d5a6148 120/195: Don't try to auto-save undo history if undo is disabled in buffer.
Date: Sat, 28 Nov 2020 13:41:35 -0500 (EST)

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

    Don't try to auto-save undo history if undo is disabled in buffer.
    
    Also check if undo is disabled in undo-tree-save-history, in case it's 
called
    interactively, and assert that buffer-undo-list is not t in
    undo-list-transfer-to-tree to aid future debugging.
    
    This fixes errors triggered by undo auto-saving when saving an undo-disabled
    buffer, and when manually calling undo-tree-save-history in an undo-disabled
    buffer.
---
 undo-tree.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/undo-tree.el b/undo-tree.el
index a6bf191..9f296fe 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2009-2012  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <toby-undo-tree@dr-qubit.org>
-;; Version: 0.5.4
+;; Version: 0.5.5
 ;; Keywords: convenience, files, undo, redo, history, tree
 ;; URL: http://www.dr-qubit.org/emacs.php
 ;; Repository: http://www.dr-qubit.org/git/undo-tree.git
@@ -1613,6 +1613,10 @@ Comparison is done with `eq'."
 (defun undo-list-transfer-to-tree ()
   ;; Transfer entries accumulated in `buffer-undo-list' to `buffer-undo-tree'.
 
+  ;; `undo-list-transfer-to-tree' should never be called when undo is disabled
+  ;; (i.e. `buffer-undo-tree' is t)
+  (assert (not (eq buffer-undo-tree t)))
+
   ;; if `buffer-undo-tree' is empty, create initial undo-tree
   (when (null buffer-undo-tree) (setq buffer-undo-tree (make-undo-tree)))
   ;; make sure there's a canary at end of `buffer-undo-list'
@@ -2903,6 +2907,7 @@ Otherwise, prompt for one.
 If OVERWRITE is non-nil, any existing file will be overwritten
 without asking for confirmation."
   (interactive)
+  (when (eq buffer-undo-list t) (error "No undo information in this buffer"))
   (undo-list-transfer-to-tree)
   (when (and buffer-undo-tree (not (eq buffer-undo-tree t)))
     (condition-case nil
@@ -3006,11 +3011,13 @@ signaling an error if file is not found."
 
 ;; Versions of save/load functions for use in hooks
 (defun undo-tree-save-history-hook ()
-  (when (and undo-tree-mode undo-tree-auto-save-history)
+  (when (and undo-tree-mode undo-tree-auto-save-history
+            (not (eq buffer-undo-list t)))
     (undo-tree-save-history nil t) nil))
 
 (defun undo-tree-load-history-hook ()
-  (when (and undo-tree-mode undo-tree-auto-save-history)
+  (when (and undo-tree-mode undo-tree-auto-save-history
+            (not (eq buffer-undo-list t)))
     (undo-tree-load-history nil t)))
 
 



reply via email to

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