emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Should org-link-parser add type "file" when link has no "file:" pref


From: joseph
Subject: Re: Should org-link-parser add type "file" when link has no "file:" prefix?
Date: Wed, 31 Jan 2024 22:10:05 +0000

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
>



reply via email to

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