emacs-orgmode
[Top][All Lists]
Advanced

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

Should org-link-parser add type "file" when link has no "file:" prefix?


From: Joseph Turner
Subject: Should org-link-parser add type "file" when link has no "file:" prefix?
Date: Thu, 28 Dec 2023 20:12:29 -0800

Hello!

I expect the following to return "[[/foobar]]":

(with-temp-buffer
  (delay-mode-hooks (org-mode))
  (insert "[[/foobar]]")
  (goto-char (point-min))
  (let ((link (org-element-link-parser)))
    (org-element-link-interpreter link nil)))

Instead, it returns "[[file:/foobar]]".

In hyperdrive.el currently, "[[/foobar]]" and "[[file:/foobar]]" have
different meanings: a link with no protocol prefix, like "[[/foobar]]",
points to a file inside of the same hyperdrive (virtual p2p folder),
whereas a link with the "file" protocol prefix, like "[[file:/foobar]]",
points to a file on the local filesystem:

https://git.sr.ht/~ushin/hyperdrive.el/tree/33d8cef0507fbbe25839a019b5c42fda862ac4de/item/hyperdrive-org.el#L137

In org-transclusion.el, org-element-context is used to parse a link, and
then org-element-link-interpreter is used to insert it into a buffer:

https://github.com/nobiot/org-transclusion/blob/b10d4de93c6c0523bd4e7e72c11ef3a9a5630370/org-transclusion.el#L372

The problem is that the "file" protocol prefix is added to links which
have no protocol prefix.  When you call org-transclusion-make-from-link
with point on "[[/foobar]]", org-transclusion.el ends up inserting this:

#+transclude: [[file:/foobar]]

which, at least with hyperdrive.el, doesn't point to the same file as

#+transclude: [[/foobar]]

All suggestions are welcome!

Thank you!!!

Joseph



reply via email to

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