"Rick Lupton" <m...@ricklupton.name> writes: > On Wed, 13 Mar 2024, at 12:30 PM, Ihor Radchenko wrote: >> I think that we can do it simpler. [...] >> The idea is to use Emacs' advice machinery to allow third-party code >> alter the functions stored in link parameters. > > I was avoiding this because I thought it was only recommended (in the elisp > manual) to use advice directly by users, not in libraries (like, I assume, > org-roam): > >> If you are writing code for release, for others to use, try to avoid >> including advice in it. If the function you want to advise has no hook to do >> the job, please talk with the Emacs developers about adding a suitable hook. >> Especially, Emacs’s own source files should not put advice on functions in >> Emacs. (There are currently a few exceptions to this convention, but we aim >> to correct them.) It is generally cleaner to create a new hook in foo, and >> make bar use the hook, than to have bar put advice in foo. > > (https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Named-Functions.html)
This is absolutely right, but only when advising named functions. What we are talking about is advising the link property value. In my previous discussions with Emacs devs, I was told that it superior to use advice system when a library wants to modify a function stored as a value of a variable - see https://yhetil.org/emacs-devel/sj0pr10mb548885b715c9875726f70f61f3...@sj0pr10mb5488.namprd10.prod.outlook.com/ > But I don't mind either way. I agree your approach is simpler if it's a > reasonable way for a third party library like org-roam to extend the org id > functions. I added the setter on main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d545ad606 We may also want to document the `add-function' approach in the manual. Maybe in a new section "Modifying Hyperlink Types", right after "Adding Hyperlink Types". -- 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>