Add simple function to insert links to other items at point

This commit is contained in:
Daniel - 2020-09-26 16:44:11 +02:00
parent f7ddab7696
commit 1c065bb46b
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
2 changed files with 17 additions and 1 deletions

View File

@ -716,7 +716,8 @@
db/org-mark-current-default-task
db/export-diary
db/org-copy-template-for-periodic-task
db/org-find-links-to-current-item))
db/org-find-links-to-current-item
db/org-add-link-to-other-item))
(use-package org
:pin "gnu"

View File

@ -635,6 +635,21 @@ prompt for an item."
(org-with-point-at pom
(list (org-id-get) (org-entry-get nil "CUSTOM_ID"))))))))
(defun db/org-add-link-to-other-item ()
"Interactively query for item and add link to it at point.
Uses `org-id-get-create' to get the ID or CUSTOM_ID propery of
the target headline."
(interactive)
(let ((pom (nth 3 (org-refile-get-location nil (get-file-buffer db/org-default-org-file)))))
(if (not pom)
(user-error "Invalid location")
(let (id item)
(save-mark-and-excursion
(org-with-point-at pom
(setq item (org-entry-get nil "ITEM")
id (org-id-get-create)))
(insert (format "[[id:%s][%s]]" id item)))))))
;;; End