From c219d77ab91e7107fcacc6a8eac33bc9910830a3 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 26 Sep 2020 15:12:49 +0200 Subject: [PATCH] Query for headline in link finder function when outside of Org Mode --- site-lisp/db-org.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 11201d3..11f87c6 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -595,17 +595,21 @@ This is done only if the value of this variable is not null." ;;; Find items by link to current headline -;; TODO: expand: let the user choose the item that is to be linked to -;; interactively (defun db/org-find-items-linking-by-id (&optional id custom-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', and CUSTOM-ID -must consist of ASCII letters, numbers, and hyphens only. If ID -and CUSTOM-ID are not given, use the values of the current item -if in Org Mode." - (interactive (when (derived-mode-p 'org-mode) - (list (org-id-get) (org-entry-get nil "CUSTOM_ID")))) +must consist of ASCII letters, numbers, and hyphens only. When +called interactively in Org Mode, use the values ID and CUSTOM_ID +of the current item. When called interactively outside of Org +Mode, prompt the user for the user for a headline." + (interactive (if (derived-mode-p 'org-mode) + (list (org-id-get) (org-entry-get nil "CUSTOM_ID")) + (let ((pom (nth 3 (org-refile-get-location)))) + (if (not pom) + (user-error "Invalid location") + (org-with-point-at pom + (list (org-id-get) (org-entry-get nil "CUSTOM_ID"))))))) (unless (or (not id) (and (stringp id)