Query for headline in link finder function when outside of Org Mode

This commit is contained in:
Daniel - 2020-09-26 15:12:49 +02:00
parent 994be97397
commit c219d77ab9
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 11 additions and 7 deletions

View File

@ -595,17 +595,21 @@ This is done only if the value of this variable is not null."
;;; Find items by link to current headline ;;; 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) (defun db/org-find-items-linking-by-id (&optional id custom-id)
"List all Org Mode items that link to ID. "List all Org Mode items that link to ID.
Uses `org-search-view' to conduct the actual search. ID must be 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 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 must consist of ASCII letters, numbers, and hyphens only. When
and CUSTOM-ID are not given, use the values of the current item called interactively in Org Mode, use the values ID and CUSTOM_ID
if in Org Mode." of the current item. When called interactively outside of Org
(interactive (when (derived-mode-p 'org-mode) Mode, prompt the user for the user for a headline."
(list (org-id-get) (org-entry-get nil "CUSTOM_ID")))) (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) (unless (or (not id)
(and (stringp id) (and (stringp id)