I want to set the deadline of every org-capture per some considerations and I want to do this after the capture rather than in the capture template.
Given the following example code:
(defun post-capture ()
(save-excursion
(org-entry-put (point) "DEADLINE" (format-time-string "<%Y-%m-%d %a>" (current-time)))))
(add-hook 'org-capture-prepare-finalize-hook 'post-capture)
and the following capture template:
("t" "Personal Task" entry (file+headline org-tasks-path "INBOX")
"* NEXT %?\n" :prepend t)
The deadline gets incorrectly applied to the task below the one just captured, e.g.,
* NEXT New Task
* NEXT Old Task
DEADLINE: <xxx-xx-xx>
Change the code to any property that gets inserted into a drawer, and it works correctly. E.g.
(defun post-capture ()
(save-excursion
(org-entry-put (point) "FOO" (format-time-string "<%Y-%m-%d %a>" (current-time)))))
(add-hook 'org-capture-prepare-finalize-hook 'post-capture)
correctly yields:
* NEXT New Task
:PROPERTIES:
:FOO: <xxxx-xx-xx>
:END:
* NEXT Old Task
How can I get the DEADLINE property to be applied to the just-captured entry?