From a6f77f8d716792127a1355d15f9153fcabe31d36 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 26 Sep 2020 14:14:45 +0200 Subject: [PATCH] Add simple helper function to find items linking to the current one Only ID links are supported by now. --- init.el | 3 ++- site-lisp/db-org.el | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 140a2ad..642ab9f 100644 --- a/init.el +++ b/init.el @@ -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" diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 2de131f..32949e9 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -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