It's basically "What links here?".
Using Org mode links, I'd like to be able to get the list of headings which contain a link to a specific heading.
Example file:
* Target
:PROPERTIES:
:ID: 509039F8-5B43-4C9B-8FA3-F37E3A2EEC10
:END:
* Heading containing link
id:509039F8-5B43-4C9B-8FA3-F37E3A2EEC10
* Another heading containing the same link
id:509039F8-5B43-4C9B-8FA3-F37E3A2EEC10
When the cursor is at Target
, I'd like to get the list of all headings that link to it:
* Heading containing link
* Another heading containing the same link
(let ((id (org-entry-get (point) "ID")) result) (save-excursion (goto-char (point-min)) (while (re-search-forward (concat "id:" id) nil t) (push (org-get-heading) result)) result))
You can look atorg-id-update-id-locations
to see how to get a listing of all files that may contain ID and you can loop through each file. You can create a variation oforg-get-heading
if you need something a little different -- e.g., gather the stars, or usematch-string-no-properties
if the text properties are not to your liking.