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

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

[nongnu] elpa/hyperdrive 5d3d0cf953 9/9: Merge branch 'deleted-buffer-mo


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive 5d3d0cf953 9/9: Merge branch 'deleted-buffer-modified-p'
Date: Thu, 12 Oct 2023 16:00:56 -0400 (EDT)

branch: elpa/hyperdrive
commit 5d3d0cf9532b5ba7daf46fc54bbd2c11fdf0749c
Merge: 167bbb4a36 d158584d74
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Merge branch 'deleted-buffer-modified-p'
---
 hyperdrive-lib.el | 15 ++++++++-------
 hyperdrive.el     |  9 +++++++++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 3580dc0e28..c9b6f2ed5c 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1325,7 +1325,7 @@ Affected by option `hyperdrive-reuse-buffers', which see."
          (buffer
           (or (when (eq 'any-version hyperdrive-reuse-buffers)
                 (cl-loop for buffer in (buffer-list)
-                         when (hyperdrive--entry-buffer-p entry buffer)
+                         when (hyperdrive--buffer-visiting-entry-p buffer 
entry)
                          return buffer))
               (get-buffer-create buffer-name))))
     (with-current-buffer buffer
@@ -1342,7 +1342,7 @@ Affected by option `hyperdrive-reuse-buffers', which see."
       (setq-local hyperdrive-current-entry entry)
       (current-buffer))))
 
-(defun hyperdrive--entry-buffer-p (entry buffer)
+(defun hyperdrive--buffer-visiting-entry-p (buffer entry)
   "Return non-nil when BUFFER is visiting ENTRY."
   (and (buffer-local-value 'hyperdrive-mode buffer)
        (buffer-local-value 'hyperdrive-current-entry buffer)
@@ -1352,7 +1352,7 @@ Affected by option `hyperdrive-reuse-buffers', which see."
 (defun hyperdrive--buffer-for-entry (entry)
   "Return a predicate to match buffer against ENTRY."
   ;; TODO: This function is a workaround for bug#65797
-  (lambda (buffer) (hyperdrive--entry-buffer-p entry buffer)))
+  (lambda (buffer) (hyperdrive--buffer-visiting-entry-p buffer entry)))
 
 (defun hyperdrive--entry-buffer-name (entry)
   "Return buffer name for ENTRY."
@@ -1434,14 +1434,15 @@ When BUFFER is nil, act on current buffer."
 
 (defun hyperdrive-entry-equal-p (a b)
   "Return non-nil if hyperdrive entries A and B are equal.
-Compares only public key and path."
-  (pcase-let (((cl-struct hyperdrive-entry (path a-path)
+Compares only public key, version, and path."
+  (pcase-let (((cl-struct hyperdrive-entry (path a-path) (version a-version)
                           (hyperdrive (cl-struct hyperdrive (public-key 
a-key))))
                a)
-              ((cl-struct hyperdrive-entry (path b-path)
+              ((cl-struct hyperdrive-entry (path b-path) (version b-version)
                           (hyperdrive (cl-struct hyperdrive (public-key 
b-key))) )
                b))
-    (and (equal a-path b-path)
+    (and (eq a-version b-version)
+         (equal a-path b-path)
          (equal a-key b-key))))
 
 (defun hyperdrive-equal-p (a b)
diff --git a/hyperdrive.el b/hyperdrive.el
index fa076ab0d4..2ad0cb5c93 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -390,6 +390,15 @@ directory.  Otherwise, or with universal prefix argument
                 (setf (hyperdrive-entry-version nonexistent-entry) 
(string-to-number etag))
                 (hyperdrive--fill-latest-version (hyperdrive-entry-hyperdrive 
entry) headers)
                 (hyperdrive-update-nonexistent-version-range 
nonexistent-entry))
+              ;; Since there's no way for `hyperdrive--write-contents' to run 
when
+              ;; `buffer-modified-p' returns nil, this is a workaround to 
ensure that
+              ;; `save-buffer' re-saves files after they've been deleted.
+              (dolist (buf (match-buffers (lambda (buf deleted-entry)
+                                            (when-let ((current-entry 
(buffer-local-value 'hyperdrive-current-entry buf)))
+                                              (hyperdrive-entry-equal-p 
current-entry deleted-entry)))
+                                          nil entry))
+                (with-current-buffer buf
+                  (set-buffer-modified-p t)))
               (funcall then response)))
     :else else))
 



reply via email to

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