branch: elpa/hyperdrive
commit ce814a8d4c81c21e94cc2537db7900f27e6d437b
Author: Adam Porter <[email protected]>
Commit: Adam Porter <[email protected]>
Add/Change: (h//find-buffer-visiting)
---
hyperdrive-lib.el | 21 ++++++++-------------
hyperdrive.el | 18 ++++++++----------
2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index cdb6d98711..bf79874922 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1544,9 +1544,7 @@ Affected by option `hyperdrive-reuse-buffers', which see."
entry h/buffer-name-format))
(buffer
(or (and (eq 'any-version h/reuse-buffers)
- (cl-loop for buffer in (buffer-list)
- when (h//buffer-visiting-entry-p buffer entry)
- return buffer))
+ (h//find-buffer-visiting entry))
(get-buffer-create buffer-name))))
(with-current-buffer buffer
(rename-buffer buffer-name)
@@ -1556,16 +1554,13 @@ Affected by option `hyperdrive-reuse-buffers', which
see."
(setq-local h/current-entry entry)
(current-buffer))))
-(defun h//buffer-visiting-entry-p (buffer entry)
- "Return non-nil when BUFFER is visiting ENTRY."
- (and (buffer-local-value 'h/current-entry buffer)
- (he/equal-p
- entry (buffer-local-value 'h/current-entry buffer))))
-
-(defun h//buffer-for-entry (entry)
- "Return a predicate to match buffer against ENTRY."
- ;; TODO: This function is a workaround for bug#65797
- (lambda (buffer) (h//buffer-visiting-entry-p buffer entry)))
+(defun h//find-buffer-visiting (entry)
+ "Return a buffer visiting ENTRY, or nil if none exist."
+ (match-buffers
+ (lambda (buffer)
+ (and-let* ((local-entry
+ (buffer-local-value 'hyperdrive-current-entry buffer)))
+ (he/equal-p entry local-entry)))))
(defun h//format-entry (entry &optional format formats)
"Return ENTRY formatted according to FORMAT.
diff --git a/hyperdrive.el b/hyperdrive.el
index 3a2e8f8363..266e595170 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -435,18 +435,16 @@ use, see `hyperdrive-write'."
(unless (y-or-n-p
(format "File %s exists; overwrite?" (h//format-entry entry)))
(h/user-error "Canceled"))
- (when-let ((buffers (match-buffers (h//buffer-for-entry entry))))
+ ;; TODO: In BUFFERS, when user attempts to modify the buffer,
+ ;; offer warning like "FILE has been modified in hyperdrive; are
+ ;; you sure you want to edit this buffer?"
+ ;; TODO: Replace `match-buffers' above with `cl-find-if' if we don't
+ ;; end up adding a buffer-local variable to each buffer to
+ ;; indicate that the file in the hyperdrive has been modified.
+ (when (h//find-buffer-visiting entry)
(unless (y-or-n-p
(format "A buffer is visiting %s; proceed?" (h//format-entry
entry)))
- (h/user-error "Aborted"))
- ;; TODO: In BUFFERS, when user attempts to modify the buffer,
- ;; offer warning like "FILE has been modified in hyperdrive; are
- ;; you sure you want to edit this buffer?"
- ;; TODO: Replace `match-buffers' above with `cl-find-if' if we don't
- ;; end up adding a buffer-local variable to each buffer to
- ;; indicate that the file in the hyperdrive has been modified.
- (ignore buffers)
- ))
+ (h/user-error "Aborted"))))
(pcase-let (((cl-struct hyperdrive-entry hyperdrive name) entry)
(url (he/url entry))
(buffer (current-buffer)))