branch: elpa/hyperdrive
commit 02b77f7f4f82abc8916d13488cd022f07509e7c8
Merge: d10b6524bc 929d9dd486
Author: Joseph Turner <[email protected]>
Commit: Joseph Turner <[email protected]>
Merge branch 'org-transclusion'
---
.dir-locals.el | 2 +-
CHANGELOG.org | 5 +++++
doc/hyperdrive.org | 5 +++--
doc/hyperdrive.texi | 5 +++--
hyperdrive-describe.el | 2 +-
hyperdrive-diff.el | 2 +-
hyperdrive-dir.el | 2 +-
hyperdrive-ewoc.el | 2 +-
hyperdrive-history.el | 2 +-
hyperdrive-lib.el | 15 +++++++++++----
hyperdrive-menu.el | 2 +-
hyperdrive-mirror.el | 2 +-
hyperdrive-org.el | 11 ++++++++---
hyperdrive-vars.el | 2 +-
hyperdrive.el | 2 +-
15 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
index 5ba88fb009..65d6493da8 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,6 +1,6 @@
;;; Directory Local Variables -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")
-((nil . ((ispell-buffer-session-localwords . ("dir" "hypercore" "hyperdrive"
"hyperdrives" "hyperdrive's" "args" "systemd" "minibuffer" "petname" "petnames"
"org" "plist" "plists" "alist" "alists" "existsp" "ETag" "streamable" "DNSLink"
"ewoc" "struct" "ENTRY's" "localhost" "imenu" "mtime" "accessor" "http"
"prepended" "prepend" "hostname" "whitespace" "namespace" "filesystem"
"hostnames" "subdirectories" "unsets" "finalizer" "subprocess" "autodetect"))))
+((nil . ((ispell-buffer-session-localwords . ("dir" "hypercore" "hyperdrive"
"hyperdrives" "hyperdrive's" "args" "systemd" "minibuffer" "petname" "petnames"
"org" "plist" "plists" "alist" "alists" "existsp" "ETag" "streamable" "DNSLink"
"ewoc" "struct" "ENTRY's" "localhost" "imenu" "mtime" "accessor" "http"
"prepended" "prepend" "hostname" "whitespace" "namespace" "filesystem"
"hostnames" "subdirectories" "unsets" "finalizer" "subprocess" "autodetect"
"transclusion"))))
(emacs-lisp-mode . ((eval . (display-fill-column-indicator-mode))
(fill-column . 80))))
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 04aee796b6..f78c7fe4cd 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -12,9 +12,14 @@ This project adheres to
[[https://semver.org/spec/v2.0.0.html][Semantic Versioni
- Better error message when ~hyper-gateway~ is not installed. Thanks to
~magnum~ on XMPP for reporting.
+** Fixed
+
+- Fixed link targets/fragments for non-Org documents, like HTML.
+
** Internal
- Bumped package dependencies
+- Refactor to accommodate
[[https://ushin.org/hyperdrive/hyperdrive-manual.html#hyperdrive-org-transclusion][hyperdrive-org-transclusion]]
* 0.3 [2023-12-02 Sat]
diff --git a/doc/hyperdrive.org b/doc/hyperdrive.org
index 9e32b13844..83de76a4cb 100644
--- a/doc/hyperdrive.org
+++ b/doc/hyperdrive.org
@@ -449,8 +449,9 @@ at point by pressing ~w~ (see [[*Directory view]]).
#+vindex: org-link-file-path-type
If the current file is an org-mode file, ~org-store-link~ will store a
-link to the hyperdrive file, and if point is inside a heading, its
-~CUSTOM_ID~, ~ID~, or heading text will be appended to the stored URL.
+link to the hyperdrive file. If point is inside a heading, a
+URL-encoded search option containing its ~CUSTOM_ID~, ~ID~, or heading
+text will be appended as the stored URL's link fragment.
Relative links are supported; within ~hyper://PUBLIC-KEY/foo.org~, links
to ~bar.org~, ~./bar.org~, and ~/bar.org~ will all point to
diff --git a/doc/hyperdrive.texi b/doc/hyperdrive.texi
index 15bebee3cd..877ee12582 100644
--- a/doc/hyperdrive.texi
+++ b/doc/hyperdrive.texi
@@ -667,8 +667,9 @@ at point by pressing @code{w} (see @ref{Directory view}).
@vindex org-link-file-path-type
If the current file is an org-mode file, @code{org-store-link} will store a
-link to the hyperdrive file, and if point is inside a heading, its
-@code{CUSTOM_ID}, @code{ID}, or heading text will be appended to the stored
URL@.
+link to the hyperdrive file. If point is inside a heading, a
+URL-encoded search option containing its @code{CUSTOM_ID}, @code{ID}, or
heading
+text will be appended as the stored URL's link fragment.
Relative links are supported; within @code{hyper://PUBLIC-KEY/foo.org}, links
to @code{bar.org}, @code{./bar.org}, and @code{/bar.org} will all point to
diff --git a/hyperdrive-describe.el b/hyperdrive-describe.el
index 2cae15dd18..d42ee40803 100644
--- a/hyperdrive-describe.el
+++ b/hyperdrive-describe.el
@@ -1,6 +1,6 @@
;;; hyperdrive-describe.el --- Display information about a hyperdrive -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-diff.el b/hyperdrive-diff.el
index 4c8490cc2f..e72ea1f53f 100644
--- a/hyperdrive-diff.el
+++ b/hyperdrive-diff.el
@@ -1,6 +1,6 @@
;;; hyperdrive-diff.el --- Shared (persist-)defvars, deffaces, defcustoms -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-dir.el b/hyperdrive-dir.el
index c0c09ad446..ff1d2ba73e 100644
--- a/hyperdrive-dir.el
+++ b/hyperdrive-dir.el
@@ -1,6 +1,6 @@
;;; hyperdrive-dir.el --- Hyperdrive directory frontend -*- lexical-binding:
t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Adam Porter <[email protected]>
diff --git a/hyperdrive-ewoc.el b/hyperdrive-ewoc.el
index db609fe24b..e7c2aabeca 100644
--- a/hyperdrive-ewoc.el
+++ b/hyperdrive-ewoc.el
@@ -1,6 +1,6 @@
;;; hyperdrive-ewoc.el --- Common EWOC behavior for Hyperdrive -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-history.el b/hyperdrive-history.el
index 7e87e50552..2c13668f10 100644
--- a/hyperdrive-history.el
+++ b/hyperdrive-history.el
@@ -1,6 +1,6 @@
;;; hyperdrive-history.el --- Hyperdrive version history frontend -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 2f540dbc89..cdb6d98711 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1,6 +1,6 @@
;;; hyperdrive-lib.el --- Library functions and structures -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Adam Porter <[email protected]>
@@ -281,8 +281,10 @@ before making the entry struct."
(or (gethash host h/hyperdrives)
(h/create :public-key host)))))
(etc (and target
- `((target . ,(substring (url-unhex-string target)
- (length "::"))))))
+ `((target . ,(if (h/org-filename-p path)
+ (substring (url-unhex-string target)
+ (length "::"))
+ (url-unhex-string target))))))
(version (pcase path
((rx "/$/version/" (let v (1+ num)) (let p (0+ anything)))
(setf path p)
@@ -980,7 +982,8 @@ Path and target fragment are URI-encoded."
(target-part (and with-target
target
(concat "#"
- (url-hexify-string "::")
+ (when (h/org-filename-p path)
+ (url-hexify-string "::"))
(url-hexify-string target))))
(path (and with-path
;; TODO: Consider removing this argument if it's not
needed.
@@ -1699,6 +1702,10 @@ Unless PATH starts with \"/\" \"./\" or \"../\", add
\"./\"."
path
(concat "./" path)))
+(defun h/org-filename-p (path)
+ "Return non-nil when PATH is an Org file."
+ (string-suffix-p ".org" path))
+
(provide 'hyperdrive-lib)
;; Local Variables:
diff --git a/hyperdrive-menu.el b/hyperdrive-menu.el
index b3bf5c9448..fbc077d608 100644
--- a/hyperdrive-menu.el
+++ b/hyperdrive-menu.el
@@ -1,6 +1,6 @@
;;; hyperdrive.el --- P2P filesystem -*- lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Adam Porter <[email protected]>
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-mirror.el b/hyperdrive-mirror.el
index 06956a7aa4..2748e2f35e 100644
--- a/hyperdrive-mirror.el
+++ b/hyperdrive-mirror.el
@@ -1,6 +1,6 @@
;;; hyperdrive-mirror.el --- Display information about a hyperdrive -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive-org.el b/hyperdrive-org.el
index fa101e31b4..79c281e0fa 100644
--- a/hyperdrive-org.el
+++ b/hyperdrive-org.el
@@ -1,6 +1,6 @@
;;; hyperdrive-org.el --- Org-related functionality -*- lexical-binding: t;
-*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Adam Porter <[email protected]>
@@ -129,8 +129,13 @@ the logic for handling links of \"file\" type."
"Return a hyperdrive entry for the Org link at point."
;; This function is not in the code path for full URLs or links that
;; are only search options.
- (let* ((context (org-element-lineage (org-element-context) '(link) t))
- (element-type (org-element-type context))
+ (h/org--element-entry
+ (org-element-lineage (org-element-context) '(link) t)))
+
+(defun h/org--element-entry (context)
+ "Return the hyperdrive entry for the Org CONTEXT.
+If CONTEXT does not correspond to a hyperdrive entry, return nil."
+ (let* ((element-type (org-element-type context))
(link-type (org-element-property :type context))
(raw-link-type (org-element-property :raw-link context)))
(and (eq element-type 'link)
diff --git a/hyperdrive-vars.el b/hyperdrive-vars.el
index 6a0db9c2a3..81b3279c70 100644
--- a/hyperdrive-vars.el
+++ b/hyperdrive-vars.el
@@ -1,6 +1,6 @@
;;; hyperdrive-vars.el --- Shared (persist-)defvars, deffaces, defcustoms -*-
lexical-binding: t; -*-
-;; Copyright (C) 2023 USHIN, Inc.
+;; Copyright (C) 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
diff --git a/hyperdrive.el b/hyperdrive.el
index 3a96297ba4..3a2e8f8363 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -1,6 +1,6 @@
;;; hyperdrive.el --- P2P filesystem -*- lexical-binding: t; -*-
-;; Copyright (C) 2022, 2023 USHIN, Inc.
+;; Copyright (C) 2022, 2023, 2024 USHIN, Inc.
;; Author: Joseph Turner <[email protected]>
;; Author: Adam Porter <[email protected]>