From: Ihor Radchenko <yantar92@posteo.net>
To: Rick Lupton <mail@ricklupton.name>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Allow external libraries (org-roam) to supply org-id locations
Date: Wed, 13 Mar 2024 12:30:37 +0000 [thread overview]
Message-ID: <87zfv2wbyq.fsf@localhost> (raw)
In-Reply-To: <715e7a79-2107-4c61-8b7c-26b68e680451@app.fastmail.com>
"Rick Lupton" <mail@ricklupton.name> writes:
> Since updating the org-id code [1] to use the standard org-link registered functions instead of hard-coding org-id opening, I have a problem using org-roam.
>
> org-roam overwrites the :follow function for "id" links from the build-in `org-id-open' to its own `org-roam-id-open' (https://github.com/org-roam/org-roam/blob/8667e441876cd2583fbf7282a65796ea149f0e5f/org-roam-id.el#L91). The only change between these functions is to insert a call to try `org-roam-id-find' before trying `org-id-find', which uses org-roam's cached sqlite database to find the id (https://github.com/org-roam/org-roam/blob/8667e441876cd2583fbf7282a65796ea149f0e5f/org-roam-id.el#L70-L71)
>
> As well as being messy, my specific problem is that the improvements to open search strings in org-id links are no longer enabled when org-roam is loaded.
>
> It seems reasonable that a library might want to provide its own way of locating org-ids. The attached patch adds a new hook variable `org-id-find-functions` which contains functions doing the same job as `org-id-find' that should be tried first. Then all org-roam needs to do is add its `org-roam-id-find' to the hook.
>
> Does this seem like a good idea?
I think that we can do it simpler.
Something like
(defun yant/message-me (&rest _) (message "I am here!") nil) ; return nil to pass the turn
(gv-define-setter org-link-get-parameter (value type key)
`(org-link-set-parameters ,type ,key ,value))
(add-function :before-until (org-link-get-parameter "id" :follow) #'yant/message-me)
The idea is to use Emacs' advice machinery to allow third-party code
alter the functions stored in link parameters.
Either way, org-roam needs to be adapted in order to support the changes
in org-id. My variant appears to be simpler. We just need to add
`gv-define-setter ...' and maybe also document the `add-function'
approach in the manual.
--
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>
next prev parent reply other threads:[~2024-03-13 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 23:18 [PATCH] Allow external libraries (org-roam) to supply org-id locations Rick Lupton
2024-03-13 12:30 ` Ihor Radchenko [this message]
2024-03-16 22:46 ` Rick Lupton
2024-03-17 10:17 ` Ihor Radchenko
2024-03-17 22:54 ` Rick Lupton
2024-03-20 10:30 ` Ihor Radchenko
2024-04-20 11:07 ` Ihor Radchenko
2024-05-02 13:23 ` Rick Lupton
2024-05-02 13:28 ` 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=87zfv2wbyq.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=mail@ricklupton.name \
/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).