Joseph Turner <jos...@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. >> 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. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>