Le mar. 16 juin 2026 à 10:02, Greg Coladonato <[email protected]> a écrit :
>
> (please be gentle, this is the first time I've ever tried contributing source
> code like this :)
>
> When I org-store-link to Sub in this file:
>
> #+TITLE: Test
> * Top
> ** Sub
>
> I currently get [[id:260616_075039][Sub]] (I have my own id timestamp
> generator)
>
> I often have a generic word like Todos or Notes in place of Sub, so that the
> link text isn't a good reminder of what it's linking to. I would like it to
> be [[id:260616_075039][Test > Top > Sub]]
>
> I haven't seen any discussion of this in the archives. Criticism welcome.
>
> Cheers,
> Greg
>
> --
> Sent from my Palm Pilot
This is a great idea.
> + (let ((heading (if (match-end 4)
> + (match-string-no-properties 4)
> + (match-string-no-properties 0))))
> + (if org-id-link-description-include-outline-path
As of now, your code does not respect `org-link-context-for-files' and
`org-id-link-use-context'. Currently, org-id will only create a
description for a link if the value of both of those variables is
non-nil:
> (precise-target (and org-link-context-for-files
> org-id-link-use-context
> (org-link-precise-link-target))
With your change, a link description will always be created even if
those values are nil. That actually leads me to my next point, which
is that the outline path code would fit better in
org-link-precise-target instead of org-id-store-link. That would of
course also mean you would need to move the defcustom you created to
ol.el. But with that change, the values of
`org-link-context-for-files' and `org-id-link-use-context' would
always be respected and your code could be used to create link
descriptions for links that are not created by org-id. When you do
that, I suggest you also create a test.
> + (let* ((olp (org-get-outline-path))
> + (title (cadr (assoc "TITLE"
> + (org-collect-keywords
> + '("TITLE")))))
> + (parts (append (when title (list title))
> + olp
> + (list heading))))
> + (mapconcat #'identity parts " > "))
> + heading)))
You can simplify your code by using `org-display-outline-path'. The
equivalent to the above code would be: (org-display-outline-path
'title t " > " t).