emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joseph Turner <joseph@ushin.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org, Adam Porter <adam@alphapapa.net>
Subject: Re: Should org-link-parser add type "file" when link has no "file:" prefix?
Date: Sat, 13 Jan 2024 23:10:09 -0800	[thread overview]
Message-ID: <87v87v0zno.fsf@ushin.org> (raw)
In-Reply-To: <87ttnvan3m.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 3829 bytes --]

Ihor Radchenko <yantar92@posteo.net> writes:

> Joseph Turner <joseph@ushin.org> writes:
>
>>> See `org-open-file' IN-EMACS argument - we may use different handlers
>>> to open file links. Currently, IN-EMACS can be 'system or 'emacs. But
>>> nothing stops us from adding more options.
>>
>> Thanks!  Are you suggesting something like [[file+hyper:/README.org]] ?
>
> Yes.

Thanks - that could be useful.

>>> This will cause major issues when trying to export such links.
>>> Except for HTML export that utilizes `org-html-link-use-abs-url', but
>>> only for relative links.
>>
>> Yes, there are many users who rely on [[file:/index.html]] exporting to
>> <a href="/index.html"> instead of <a href="file:///index.html">.
>
> This is not what Org HTML export does. Only relative links are affected
> by `org-html-link-use-abs-url':
>
> Documentation
> Should we prepend relative links with HTML_LINK_HOME?
>
> Absolute links always remain absolute.

You're right.  I just meant that ox-html should keep the existing
behavior when exporting implicit file: links.  Many websites would break
if implicit file: links started exporting as <a href="/index.html">.

>>> Why not make [[hyper:/README.org]] use the "default" hyperdrive the
>>> Org file belongs to.
>>
>> I'd like for users to be able to take an existing directory of Org mode
>> documents and copy them all into a hyperdrive.  I think the least
>> surprising behavior is for the links between those files to continue
>> working.  Perhaps the best option is for hyperdrive.el to make all "file"
>> type links, explicit or not, point to other files inside the hyperdrive?
>>
>> In that case, there would be no way for Org mode files in a hyperdrive
>> to point to the local filesystem.  Similarly, when Org documents are
>> exported to HTML, there's no way to export <a href="file:///index.html">.
>
> May you please elaborate? How is hyperdrive directory different from
> local directory?

On disk, hyperdrive data is stored by hash prefixes like so:

/home/joseph/.local/share/hyper-gateway-nodejs/cores/
└── 00
    ├── 6a
    │   └── 006ae0628e1fad7c357fd4a1c6103d37bcb70797c6f0dba77c261871306b16b3
    │       ├── bitfield
    │       ├── data
    │       ├── oplog
    │       └── tree
    └── de
        └── 00de65a26162bbaad8f97bb89e81856ac1dd6a1bc10a46f06086b4a25b244ad5
            ├── data
            ├── oplog
            └── tree

This is similar to the way .git/objects/ directories are structured.

Of course, inspecting the storage directories of this kind with Dired
does not provide a meaningful UI.  Special software is required for
users to explore and open the hyperdrive "directories" and "files".

To push the git analogy further, the way hyperdrive-find-file is like
magit-find-file.  Both use an external program, git or hyper-gateway, to
pick out the correct data and present it to Emacs as if it were a file.

Does that answer your question?

>>> For example, see WIP patch where we expose setting id: link properties:
>>> https://list.orgmode.org/orgmode/c98a38b0-6dea-4b5c-b00f-a39ea922537f@app.fastmail.com/
>>
>> How would the :follow function for "file:" links get access to the link
>> search option?  IIUC, `org-link-open' handles "file:" links specially because
>> they require
>>
>> (org-element-property :search-option link)
>
> :follow functions are passed both path and search option.

How is the search option passed in?

IIUC in org-link-open, the path argument passed in has no search option:

(funcall (org-link-get-parameter type :follow) path arg)

By the way, I think this minor improvement could be made at the bottom
of org-link-open:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ol.el-org-link-open-Use-let-bound-follow-functi.patch --]
[-- Type: text/x-diff, Size: 969 bytes --]

From 0c83446f16441df39618e43f964e18f672205d55 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Mon, 15 Jan 2024 00:24:30 -0800
Subject: [PATCH] lisp/ol.el (org-link-open): Use let-bound :follow function

---
 lisp/ol.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index 779175403..9bc2f5fb0 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1125,9 +1125,9 @@ (defun org-link-open (link &optional arg)
 	   ;; argument, as it was mandatory before Org 9.4.  This is
 	   ;; deprecated, but support it for now.
 	   (condition-case nil
-	       (funcall (org-link-get-parameter type :follow) path arg)
+	       (funcall f path arg)
 	     (wrong-number-of-arguments
-	      (funcall (org-link-get-parameter type :follow) path)))))))))
+	      (funcall f path)))))))))
 
 (defun org-link-open-from-string (s &optional arg)
   "Open a link in the string S, as if it was in Org mode.
-- 
2.41.0


[-- Attachment #3: Type: text/plain, Size: 20 bytes --]


Thank you!

Joseph

  reply	other threads:[~2024-01-15  8:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29  4:12 Should org-link-parser add type "file" when link has no "file:" prefix? Joseph Turner
2023-12-29 14:49 ` Ihor Radchenko
2023-12-29 22:05   ` Joseph Turner
2023-12-30 21:12     ` Joseph Turner
2023-12-31 15:07     ` Ihor Radchenko
2024-01-01  6:52       ` Joseph Turner
2024-01-02 13:20         ` Ihor Radchenko
2024-01-14  7:10           ` Joseph Turner [this message]
2024-01-16 13:40             ` Ihor Radchenko
2024-01-16 20:16               ` Joseph Turner
2024-01-17 13:15                 ` Ihor Radchenko
2024-01-31 22:10                   ` joseph
2024-02-01 12:23                     ` Ihor Radchenko
2024-02-02  4:35                       ` joseph
2024-02-02 16:01                         ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v87v0zno.fsf@ushin.org \
    --to=joseph@ushin.org \
    --cc=adam@alphapapa.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).