From: 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: Wed, 31 Jan 2024 22:10:05 +0000 [thread overview]
Message-ID: <cb002f59f59c0e9add40948ab056664505768929@ushin.org> (raw)
In-Reply-To: <87ttnchzi2.fsf@localhost>
January 17, 2024 at 5:15 AM, "Ihor Radchenko" <yantar92@posteo.net> wrote:
>
> Joseph Turner <joseph@ushin.org> writes:
>
> >
> > >
> > > May you please provide an example with an Org file containing file links
> > >
> > > and how you envision to transform them? Will they be transformed
> > >
> > > depending on the directory the Org file is located in?
> > >
> >
> > I don't want to transform the file links. The idea is that an Org file
> >
> > "foo.org" could be copied into a hyperdrive, and [[./bar.org]] would
> >
> > point to a file called "bar.org" in the same folder in the hyperdrive.
> >
> > That way, you could copy both "foo.org" and "bar.org" from your local
> >
> > directory into a hyperdrive, the links between them would work as-is.
> >
> > Pseudo-code for a hyperdrive.el :follow function for file: links:
> >
> > (defun hyperdrive--org-file-link-follow (url &optional _prefix _link)
> >
> > (when hyperdrive-mode
> >
> > (hyperdrive-open
> >
> > (hyperdrive-convert-path-to-hyper-url url option)) ;; Turns "/foo" into "hyper://PUBLIC-KEY/foo"
> >
> > t))
> >
> > (org-link-set-parameters "file" :follow #'hyperdrive--org-file-link-follow)
> >
>
> You do not really need Org mode to do this. Instead, it may be
>
> sufficient to define a file handler in order to make things work
>
> "magically". Check out 26.12 Making Certain File Names "Magic" section
>
> of Elisp manual.
Thank you! I've added a note to look into that: https://todo.sr.ht/~ushin/ushin/168#event-288786
> >
> > >
> > > What we can do then is pass an extra argument to :follow function - the
> > >
> > > link object. That way, :follow function can get all the information it
> > >
> > > needs.
> > >
> >
> > I like this idea! Would this change break existing :follow functions
> >
> > which only expect max two args?
> >
>
> No. We can preserve backwards-compatibility by checking :follow function
>
> arity and only passing the extra argument with the :follow function
>
> supports that many arguments.
Good to know. If the goals of hyperdrive.el can be accomplished without adding complexity to Org mode, it may be best to avoid avoid adding another argument to :follow functions. WDYT?
> --
>
> Ihor Radchenko // yantar92,
>
> Org mode contributor,
>
> Learn more about Org mode at <https://orgmode.org/> https://orgmode.org/%3E .
>
> Support Org development at <https://liberapay.com/org-mode>, https://liberapay.com/org-mode%3E,
>
> or support my work at <https://liberapay.com/yantar92> https://liberapay.com/yantar92%3E
>
next prev parent reply other threads:[~2024-01-31 22:11 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
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 [this message]
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=cb002f59f59c0e9add40948ab056664505768929@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).