branch: elpa/hyperdrive
commit 38e110b99fc9f1cbf964797c735e43d243317baf
Author: Joseph Turner <jos...@ushin.org>
Commit: Joseph Turner <jos...@ushin.org>

    Change: (hyperdrive-open) Add createp flag
    
    This allows for a hyperdrive-view-file function.
---
 hyperdrive-lib.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 03114f3f71..6f81c722d2 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -393,11 +393,12 @@ When VERSION is nil, return latest version of ENTRY."
          (_ (signal (car err) (cdr err))))))))
 
 (declare-function hyperdrive-history "hyperdrive-history")
-(cl-defun hyperdrive-open (entry &key then recurse)
+(cl-defun hyperdrive-open (entry &key then recurse (createp t))
   "Open hyperdrive ENTRY.
 If RECURSE, proceed up the directory hierarchy if given path is
-not found.  THEN may be a function to pass to the handler to call
-in the buffer opened by the handler."
+not found. THEN may be a function to pass to the handler to call
+in the buffer opened by the handler. When a writable ENTRY is not
+found and CREATEP is non-nil, create a new buffer for ENTRY."
   (declare (indent defun))
   ;; TODO: Add `find-file'-like interface. See 
<https://todo.sr.ht/~ushin/ushin/16>
   ;; TODO: When possible, check whether drive is writable with a HEAD request, 
and set writablep in the
@@ -446,7 +447,8 @@ in the buffer opened by the handler."
                      ;; Root directory not found: Drive has not been
                      ;; loaded locally, and no peers are found seeding it.
                      (hyperdrive-message "No peers found for %s" 
(hyperdrive-entry-url entry)))
-                    ((and (not (hyperdrive--entry-directory-p entry))
+                    ((and createp
+                          (not (hyperdrive--entry-directory-p entry))
                           (hyperdrive-writablep hyperdrive)
                           (not (hyperdrive-entry-version entry)))
                      ;; Entry is a writable file: create a new buffer

Reply via email to