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

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

[nongnu] elpa/undo-fu-session ddb5c29f7b 49/53: Fix #4: resolve conflict


From: ELPA Syncer
Subject: [nongnu] elpa/undo-fu-session ddb5c29f7b 49/53: Fix #4: resolve conflict with whitespace-cleanup-mode
Date: Thu, 7 Jul 2022 12:05:31 -0400 (EDT)

branch: elpa/undo-fu-session
commit ddb5c29f7b46a1ee19af01b9fc99cb41eeedf0aa
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix #4: resolve conflict with whitespace-cleanup-mode
    
    Use write-file-functions instead of before-save-hook,
    this is what undo-tree does so it seems likely this is
    better supported behavior.
---
 undo-fu-session.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/undo-fu-session.el b/undo-fu-session.el
index ae8a229d94..f4818ba24e 100755
--- a/undo-fu-session.el
+++ b/undo-fu-session.el
@@ -554,11 +554,13 @@ Argument PENDING-LIST an `pending-undo-list' compatible 
list."
           t)))))
 
 (defun undo-fu-session-save-safe ()
-  "Public save function, typically called by `before-save-hook'."
+  "Public save function, typically called by `write-file-functions'."
   (when (bound-and-true-p undo-fu-session-mode)
     (condition-case err
       (undo-fu-session--save-impl)
-      (error (message "Undo-Fu-Session can not save undo data: %s" 
(error-message-string err))))))
+      (error (message "Undo-Fu-Session can not save undo data: %s" 
(error-message-string err)))))
+  ;; Important to return NIL, to show the file wasn't saved.
+  nil)
 
 (defun undo-fu-session-save ()
   "Save undo data."
@@ -682,12 +684,12 @@ Argument PENDING-LIST an `pending-undo-list' compatible 
list."
     ;; These files should only readable by the owner, see #2.
     ;; Setting the executable bit is important for directories to be writable.
     (set-file-modes undo-fu-session-directory #o700))
-  (add-hook 'before-save-hook #'undo-fu-session-save-safe)
+  (add-hook 'write-file-functions #'undo-fu-session-save-safe)
   (add-hook 'find-file-hook #'undo-fu-session-recover-safe))
 
 (defun undo-fu-session-mode-disable ()
   "Turn off 'undo-fu-session-mode' for the current buffer."
-  (remove-hook 'before-save-hook #'undo-fu-session-save-safe t)
+  (remove-hook 'write-file-functions #'undo-fu-session-save-safe t)
   (remove-hook 'find-file-hook #'undo-fu-session-recover-safe t))
 
 (defun undo-fu-session-mode-turn-on ()



reply via email to

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