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

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

[nongnu] elpa/hyperdrive 341f145411 33/82: Add: (hyperdrive--ensure-dot-


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive 341f145411 33/82: Add: (hyperdrive--ensure-dot-slash-prefix-path)
Date: Mon, 25 Sep 2023 19:00:52 -0400 (EDT)

branch: elpa/hyperdrive
commit 341f1454113f154ee4da805d0bd6e348b010dcb1
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>

    Add: (hyperdrive--ensure-dot-slash-prefix-path)
---
 hyperdrive-lib.el |  6 ++++++
 hyperdrive-org.el | 23 ++++++++++-------------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index fece38561a..5f5297311a 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1433,5 +1433,11 @@ Compares their public keys."
   "Return non-nil if entries A and B have the same hyperdrive."
   (hyperdrive-equal-p (hyperdrive-entry-hyperdrive a) 
(hyperdrive-entry-hyperdrive b)))
 
+(defun hyperdrive--ensure-dot-slash-prefix-path (path)
+  "Return PATH. Unless PATH starts with \"/\" \"./\" or \"../\", add \"./\"."
+  (if (string-match-p (rx bos (or "/" "./" "../")) path)
+      path
+    (concat "./" path)))
+
 (provide 'hyperdrive-lib)
 ;;; hyperdrive-lib.el ends here
diff --git a/hyperdrive-org.el b/hyperdrive-org.el
index 721b3f225f..f01da59c7b 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -217,25 +217,22 @@ Respects `hyperdrive-org-link-full-url' and 
`org-link-file-path-type'."
                                                  (hyperdrive-entry-path 
hyperdrive-current-entry))
                                                 (hyperdrive-entry-path 
target-entry))
                                ;; Link points to file in same directory tree: 
use relative link.
-                               (concat "./"
-                                       (file-relative-name
-                                        (hyperdrive-entry-path target-entry)
-                                        (file-name-directory 
(hyperdrive-entry-path target-entry))))
+                               (file-relative-name
+                                (hyperdrive-entry-path target-entry)
+                                (file-name-directory (hyperdrive-entry-path 
target-entry)))
                              (hyperdrive-entry-path target-entry))))
                     ('relative
                      (setf destination
-                           (concat "./"
-                                   (file-relative-name
-                                    (hyperdrive-entry-path target-entry)
-                                    (file-name-directory 
(hyperdrive-entry-path target-entry)))))))))
+                           (file-relative-name
+                            (hyperdrive-entry-path target-entry)
+                            (file-name-directory (hyperdrive-entry-path 
target-entry))))))))
 
       ;; Link points to same hyperdrive as the file the link is in:
       ;; make link relative.
-      (setf destination (concat "./"
-                                (file-relative-name
-                                 (hyperdrive-entry-path target-entry)
-                                 (file-name-directory (hyperdrive-entry-path 
target-entry))))))
-    destination))
+      (setf destination (file-relative-name
+                         (hyperdrive-entry-path target-entry)
+                         (file-name-directory (hyperdrive-entry-path 
target-entry)))))
+    (hyperdrive--ensure-dot-slash-prefix-path destination)))
 
 ;;;###autoload
 (with-eval-after-load 'org



reply via email to

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