Use org-store-link for adding links to other items

This commit is contained in:
Daniel - 2020-09-26 18:10:34 +02:00
parent 68c6423cae
commit 4efb8cfe18
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 3 additions and 5 deletions

View File

@ -637,8 +637,7 @@ prompt for an item."
(defun db/org-add-link-to-other-item () (defun db/org-add-link-to-other-item ()
"Interactively query for item and add link to it at point. "Interactively query for item and add link to it at point.
Uses `org-id-get-create' to get the ID property of the target Use `org-store-link' to save link to `org-stored-links'."
headline."
(interactive) (interactive)
(unless (derived-mode-p 'org-mode) (unless (derived-mode-p 'org-mode)
(user-error "Not in Org Mode")) (user-error "Not in Org Mode"))
@ -648,9 +647,8 @@ headline."
(let (id item) (let (id item)
(save-mark-and-excursion (save-mark-and-excursion
(org-with-point-at pom (org-with-point-at pom
(setq item (org-entry-get nil "ITEM") (org-store-link nil t))
id (org-id-get-create))) (insert (apply #'format "[[%s][%s]]" (cl-first org-stored-links))))))))
(insert (format "[[id:%s][%s]]" id item)))))))
;;; End ;;; End