On Saturday, October 11, 2025, Ihor Radchenko wrote: [..] > Please, do not touch org-store-link. All the ID property handling is in > org-id.el.
Hm - I tried to set a breakpoint to see when ‘org-link-precise-link-target’ is actually being executed. And with the current ol.el on my disk (Emacs 30.1.90), it only gets executed when CUSTOM_ID is set. It happens in the below snippet where the CUSTOM_ID property is checked: --8<---------------cut here---------------start------------->8--- ;; org-store-link: ;; https://cgit.git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ol.el#n2570 ... (when (and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode) (org-entry-get nil "CUSTOM_ID")) --8<---------------cut here---------------end--------------->8--- >> 2. I have extended ‘org-link-precise-link-target’ to store an id: >> link if the ID is set. > > I think you misunderstood the purpose of > org-link-precise-link-target. Yes. I tried to do something similar as is done with CUSTOM_ID. > It is not intended to return id:<heading id>, but to provide > <search string> in id:<heading id>::<search string>. > > In your case, you need to extend > > ((derived-mode-p 'org-mode) > (let* ((element (org-element-at-point)) > (name (org-element-property :name element)) > (heading (org-element-lineage element '(headline > inlinetask) t)) > (custom-id (org-entry-get heading "CUSTOM_ID"))) > (cond > (name > (list name > name > (org-element-begin element))) > ((org-before-first-heading-p) > (list (org-link--normalize-string (org-current-line-string) t) > nil > (line-beginning-position))) > (heading > (list (if custom-id (concat "#" custom-id) > (org-link-heading-search-string)) > (org-link--normalize-string > (org-get-heading t t t t)) > (org-element-begin heading)))))) > > to check when point is at dedicated target and, when yes, return target > name as search string. Like what is done for NAME, but you will need to > use org-element-context to check whether there is target at point. Sorry - I am not that deep into elisp to provide a better patch right now. -- Christian Barthel
