[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive c536bc9a2c 11/82: WIP
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive c536bc9a2c 11/82: WIP |
Date: |
Mon, 25 Sep 2023 19:00:50 -0400 (EDT) |
branch: elpa/hyperdrive
commit c536bc9a2cf2efb485262d0ec3a66b5909bf123c
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
WIP
---
hyperdrive-org.el | 41 +++++++++++++++++------------------------
tests/test-hyperdrive.el | 18 ++++++++++++++++++
2 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/hyperdrive-org.el b/hyperdrive-org.el
index 8ff6648a8d..4cca5bfc1b 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -162,36 +162,29 @@ the current location."
(let* ((link-element (org-element-context))
(_ (cl-assert (eq 'link (car link-element))))
(target-entry (hyperdrive-url-entry (org-element-property :raw-link
link-element)))
- (host-format '(public-key))
- (with-path t)
- (fragment-prefix "#"))
- (when (equal (hyperdrive-public-key (hyperdrive-entry-hyperdrive
hyperdrive-current-entry))
- (hyperdrive-public-key (hyperdrive-entry-hyperdrive
target-entry)))
- ;; Link points to same hyperdrive as the file the link is in:
- ;; make link relative.
- (setf host-format nil))
- (when (equal (hyperdrive-entry-path hyperdrive-current-entry)
- (hyperdrive-entry-path target-entry))
- ;; Link points to same file: make link relative.
- (setf with-path nil)
- (when (alist-get 'target (hyperdrive-entry-etc target-entry))
- ;; HACK: Adjust target to give us the result we want.
- (setf fragment-prefix "")
- ))
-
+ (host-format '(public-key)) (with-path t) (with-protocol t)
+ fragment-prefix)
+ (cond ((hyperdrive-entry-equal-p hyperdrive-current-entry target-entry)
+ ;; Link points to same file on same hyperdrive: make link
+ ;; relative.
+ (setf with-protocol nil
+ host-format nil
+ with-path nil))
+ ((hyperdrive-entry-hyperdrive-equal-p hyperdrive-current-entry
target-entry)
+ ;; Link points to same hyperdrive as the file the link is in:
+ ;; make link relative.
+ (setf with-protocol nil
+ host-format nil))
+ (t
+ (setf fragment-prefix (concat "#" (url-hexify-string "::")))
+ (cl-callf url-hexify-string (alist-get 'target
(hyperdrive-entry-etc target-entry)))))
(delete-region (org-element-property :begin link-element)
(org-element-property :end link-element))
(insert (org-link-make-string
(hyperdrive--format-entry-url
target-entry :fragment-prefix fragment-prefix
:with-path with-path
- :with-protocol nil :host-format host-format)))
-
-
- )
- ))
-
-
+ :with-protocol with-protocol :host-format host-format))))))
;;;###autoload
(with-eval-after-load 'org
diff --git a/tests/test-hyperdrive.el b/tests/test-hyperdrive.el
index 53e3ed2d8b..6a38fa1993 100644
--- a/tests/test-hyperdrive.el
+++ b/tests/test-hyperdrive.el
@@ -259,6 +259,24 @@ LINK is an Org link as a string."
(ert-deftest hyperdrive-link-heading-within-drive ()
"Linking to a heading within the same drive but different file.")
+;;;;;;; With protocol
+
+;; These links will look the same regardless of hyperdrive or path.
+
+(ert-deftest hyperdrive-link-different-drive-with-custom-id ()
+ (should
+ (equal "[[hyper://deadbeef/foo/bar.org#%3A%3A%23example%20ID]]"
+ (hyperdrive-test-org-link-roundtrip
+ "
+* Heading A
+:PROPERTIES:
+:CUSTOM_ID: example ID
+:END:
+<|>
+* Heading B"
+ :store-from '("deadbeef" . "/foo/bar.org")
+ :insert-into '("fredbeef" . "/foo/bar.org")))))
+
;; (hyperdrive-test-org-link-roundtrip
;; "<|>
;; * Heading A
- [nongnu] elpa/hyperdrive updated (d2413785b0 -> 903847d50e), ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 4120c3a4d5 01/82: Tidy: Variable name, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive a1901daab3 05/82: WIP, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c04e0080df 07/82: Tidy: Rename function to hyperdrive-entry-equal-p, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c536bc9a2c 11/82: WIP,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive e0f7cee105 13/82: WIP: Add test-hyperdrive-org-link.el, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive de2e028534 12/82: Docs: Clarify link types, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive eb84b2d2f5 16/82: Change: (hyperdrive-entry-create) Remove ENCODE argument, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive b2fe51ba3b 02/82: Comment: Add TODO, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive c740135a62 19/82: Change: (hyperdrive-org-link-full-url) Docstring, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 81e01fcdc8 20/82: Fix: (hyperdrive--format-entry-url) Encode ?/ in URL fragment, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 3cac9738b6 22/82: Change: (-deftest) Don't rebind hyperdrive--url-hexify-string, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive eef4f80848 23/82: Change: (hyperdrive-test-org-link tests) Change "file" to "path", ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 5709167d98 24/82: Test: different-drive-same-path-*, ELPA Syncer, 2023/09/25
- [nongnu] elpa/hyperdrive 9f102bdf44 29/82: Change: (hyperdrive--org-normalize-link) Assert current entry, ELPA Syncer, 2023/09/25