Add simple function to find template via special property

This allows both a more fine-grained and more flexible control over where
templates can be located and which templates are suppoed to be used for the item
at point.  This function could also be bound to a custom key binding to make it
easier to invoke.
Daniel Borchmann 12 months ago
parent eafebe1cb9
commit 80eeca1e44
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
  1. 14

@ -588,6 +588,20 @@ drawers, will be copied to point."
(db/org-copy-body-from-item-to-point template-pom)))
(defun db/org-copy-template-from-id ()
"Copy template given by current value of TEMPLATE_ID property to point.
The TEMPLATE_ID property must be an ID property of another item
from which the contents is supposed to be copied to point."
(let ((template-id (org-entry-get (point) "TEMPLATE_ID"))
(unless template-id
(user-error "Property TEMPLATE_ID not set, cannot copy from there"))
(setq template-pom (org-id-find template-id :get-marker))
(unless template-pom
(user-error "Cannot find item with id %s" template-id))
(db/org-copy-body-from-item-to-point template-pom)))
(defun db/org-copy-body-from-item-to-point (pom)
"Copy body from item given by POM to point.