Add simple helper function to find items linking to the current one

Only ID links are supported by now.
This commit is contained in:
Daniel - 2020-09-26 14:14:45 +02:00
parent b1d82f875f
commit a6f77f8d71
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
2 changed files with 16 additions and 1 deletions

View File

@ -715,7 +715,8 @@
db/find-csv-in-org
db/org-mark-current-default-task
db/export-diary
db/org-copy-template-for-periodic-task))
db/org-copy-template-for-periodic-task
db/org-find-items-linking-to-id))
(use-package org
:pin "gnu"

View File

@ -592,6 +592,20 @@ This is done only if the value of this variable is not null."
(org-icalendar-combine-agenda-files)
(message "Exporting diary ... done.")))))))
;;; Find items by link to current headline
(defun db/org-find-items-linking-to-id (&optional id)
"List all Org Mode items that link to ID.
Uses `org-search-view' to conduct the actual search. ID must be
a UUID as generated by, e.g., `org-id-get-create'. If ID is not
given, use the ID of the current item, if in Org Mode."
(interactive (list (when (derived-mode-p 'org-mode)
(org-id-get))))
(if id
(org-search-view nil (format "[id:%s]" id))
(user-error "No ID given and not in Org Mode.")))
;;; End