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

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

[nongnu] elpa/hyperdrive 8c4c989c01 75/82: WIP: Don't store "::" in targ


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive 8c4c989c01 75/82: WIP: Don't store "::" in target in entry etc slot
Date: Mon, 25 Sep 2023 19:00:56 -0400 (EDT)

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

    WIP: Don't store "::" in target in entry etc slot
---
 hyperdrive-lib.el |  5 +++--
 hyperdrive-org.el | 15 ++++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index b033121056..0e8218c259 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -271,7 +271,7 @@ before making the entry struct."
                               (or (gethash host hyperdrive-hyperdrives)
                                   (hyperdrive-create :public-key host)))))
                (etc (when target
-                      (list (cons 'target (url-unhex-string target)))))
+                      `((target . ,(substring (url-unhex-string target) 
(length "::"))))))
                (version (pcase path
                           ((rx "/$/version/" (let v (1+ num)) (let p (0+ 
anything)))
                            (setf path p)
@@ -970,7 +970,8 @@ 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 "#" (url-hexify-string target))))
+                              (concat "#" (url-hexify-string "::")
+                                      (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 b558b18202..524bfaf9da 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -94,8 +94,8 @@ raw URL, not an Org link."
   (when hyperdrive-mode
     (let* ((heading (org-entry-get (point) "ITEM"))
            (custom-id (org-entry-get (point) "CUSTOM_ID"))
-           (fragment (cond (custom-id (concat "::#" custom-id))
-                           (heading (concat "::*" heading))))
+           (fragment (cond (custom-id (concat "#" custom-id))
+                           (heading (concat "*" heading))))
            (entry-copy (hyperdrive-copy-tree hyperdrive-current-entry t))
            (_ (setf (alist-get 'target (hyperdrive-entry-etc entry-copy)) 
fragment))
            (raw-url (hyperdrive-entry-url entry-copy)))
@@ -118,8 +118,7 @@ raw URL, not an Org link."
   "Go to TARGET in current Org buffer.
 TARGET may be a CUSTOM_ID or a headline."
   (cl-assert (eq 'org-mode major-mode))
-  ;; Remove leading "::" from target.
-  (org-link-search (substring target (length "::"))))
+  (org-link-search target))
 
 (defun hyperdrive-org-link-complete ()
   "Create a hyperdrive org link."
@@ -179,9 +178,11 @@ FIXME: Docstring, maybe move details from 
`hyperdrive-org-link-full-url'."
   (let ((search-option (alist-get 'target (hyperdrive-entry-etc entry))))
     (when (and search-option
                (hyperdrive-entry-equal-p hyperdrive-current-entry entry))
-      ;; Search option alone: Remove leading "::"
-      (cl-return-from hyperdrive--org-shorthand-link
-        (substring search-option (length "::"))))
+      (cl-return-from hyperdrive--org-shorthand-link search-option))
+
+    ;; Search option alone: Remove leading "::"
+    (when search-option
+      (cl-callf2 concat "::" search-option))
 
     (let ((adaptive-target-p
            ;; See the `adaptive' option in `org-link-file-path-type'.



reply via email to

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