Add simple function to insert links to other items at point

master
Daniel Borchmann 2 years ago
parent f7ddab7696
commit 1c065bb46b
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
  1. 3
      init.el
  2. 15
      site-lisp/db-org.el

@ -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"

@ -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

Loading…
Cancel
Save