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

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

[nongnu] elpa/hyperdrive 505ee2626b 45/82: Change: (hyperdrive--format-e


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive 505ee2626b 45/82: Change: (hyperdrive--format-entry-url) Hardcode fragment-prefix to #
Date: Mon, 25 Sep 2023 19:00:53 -0400 (EDT)

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

    Change: (hyperdrive--format-entry-url) Hardcode fragment-prefix to #
---
 hyperdrive-lib.el |  3 +--
 hyperdrive-org.el | 53 ++++++++++++++++++++++++++++-------------------------
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 5f5297311a..ed69d98b8a 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -936,7 +936,6 @@ When WITH-VERSION or ENTRY's version is nil, omit 
(version:VERSION)."
 
 (cl-defun hyperdrive--format-entry-url
     (entry &key (host-format '(public-key domain))
-           (fragment-prefix "#")
            (with-path t)
            (with-protocol t) (with-help-echo t) (with-target t) (with-faces t))
   "Return ENTRY's URL.
@@ -971,7 +970,7 @@ Path and target fragment are URI-encoded."
                (version-part (and version (format "/$/version/%s" version)))
                ((map target) etc)
                (target-part (when (and with-target target)
-                              (concat fragment-prefix (url-hexify-string 
target))))
+                              (concat "#" (url-hexify-string target))))
                (path (when with-path
                        (hyperdrive--url-hexify-string path)))
                (url (concat protocol host version-part path target-part)))
diff --git a/hyperdrive-org.el b/hyperdrive-org.el
index 4e7b3b5181..63e11d6373 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -186,26 +186,30 @@ FIXME: Docstring, maybe move details from 
`hyperdrive-org-link-full-url'."
   (let* ((url (org-element-property :raw-link link-element))
          (target-entry (hyperdrive-url-entry url))
          (search-option (alist-get 'target (hyperdrive-entry-etc 
target-entry)))
-         (host-format '(public-key)) (with-path t) (with-protocol t)
-         fragment-prefix)
-
-    (when (and search-option
-               (hyperdrive-entry-equal-p hyperdrive-current-entry 
target-entry))
-      ;; Search option alone
-      (cl-return-from hyperdrive--org-normalize-link search-option))
+         (host-format '(public-key)) (with-path t) (with-protocol t))
 
     (when (or hyperdrive-org-link-full-url
               (not (hyperdrive-entry-hyperdrive-equal-p
                     hyperdrive-current-entry target-entry)))
       ;; Full "hyper://" URL
       (when search-option
-        (setf fragment-prefix (concat "#" (url-hexify-string "::"))))
+        ;; When linking to a different file, prefix search option with "::".
+        (cl-callf2 concat "::" (alist-get 'target (hyperdrive-entry-etc 
target-entry))))
       (cl-return-from hyperdrive--org-normalize-link
         (hyperdrive--format-entry-url
-         target-entry :fragment-prefix fragment-prefix
+         target-entry
          :with-path with-path
          :with-protocol with-protocol :host-format host-format)))
 
+    (when (and search-option
+               (hyperdrive-entry-equal-p hyperdrive-current-entry 
target-entry))
+      ;; Search option alone
+      (cl-return-from hyperdrive--org-normalize-link search-option))
+
+    (when search-option
+      ;; When linking to a different file, prefix search option with "::".
+      (cl-callf2 concat "::" search-option))
+
     (let ((adaptive-target-p
            ;; See the `adaptive' option in `org-link-file-path-type'.
            (string-prefix-p
@@ -213,22 +217,21 @@ FIXME: Docstring, maybe move details from 
`hyperdrive-org-link-full-url'."
              (hyperdrive-entry-path hyperdrive-current-entry))
             (hyperdrive-entry-path target-entry))))
       (hyperdrive--ensure-dot-slash-prefix-path
-       (apply #'concat
-              (pcase org-link-file-path-type
-                ;; TODO: Handle `org-link-file-path-type' as a function.
-                ((or 'absolute
-                     ;; TODO: Consider special-casing `noabbrev' - who knows?
-                     ;; `noabbrev' is like `absolute' because hyperdrives have
-                     ;; no home directory.
-                     'noabbrev
-                     (and 'adaptive (guard (not adaptive-target-p))))
-                 (hyperdrive-entry-path target-entry))
-                ((or 'relative (and 'adaptive (guard adaptive-target-p)))
-                 (file-relative-name
-                  (hyperdrive-entry-path target-entry)
-                  (file-name-directory (hyperdrive-entry-path 
hyperdrive-current-entry)))))
-              (when search-option
-                (list "::" search-option)))))))
+       (concat
+        (pcase org-link-file-path-type
+          ;; TODO: Handle `org-link-file-path-type' as a function.
+          ((or 'absolute
+               ;; TODO: Consider special-casing `noabbrev' - who knows?
+               ;; `noabbrev' is like `absolute' because hyperdrives have
+               ;; no home directory.
+               'noabbrev
+               (and 'adaptive (guard (not adaptive-target-p))))
+           (hyperdrive-entry-path target-entry))
+          ((or 'relative (and 'adaptive (guard adaptive-target-p)))
+           (file-relative-name
+            (hyperdrive-entry-path target-entry)
+            (file-name-directory (hyperdrive-entry-path 
hyperdrive-current-entry)))))
+        search-option)))))
 
 ;;;###autoload
 (with-eval-after-load 'org



reply via email to

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