If you look at the org-capture code, there's a :default-time
property which by default uses the current time or the value of org-overriding-default-time
. What the advice does is it shifts today's date by one day and assigns the new date to that variable, which is obviously a workaround so use it with caution:
(advice-add 'org-capture :around
(lambda (oldfun &rest args)
(let ((org-overriding-default-time
(funcall
(lambda ()
(let ((day (string-to-number (format-time-string "%d")))
(month (string-to-number (format-time-string "%m")))
(year (string-to-number (format-time-string "%Y"))))
(encode-time 1 1 0 (1+ day) month year))))))
(apply oldfun args))))
You can also find or create an entry with a future date using the org-datetree-find-date-create
function. Note that 86400 is the number of seconds in one day, so what the datetree-tomorrow
function does is it adds that number to the current time to get tomorrow's date. Now you should be able to use this function in your template without having to advice org-capture.
(defun datetree-tomorrow ()
(org-datetree-find-date-create
(calendar-gregorian-from-absolute
(time-to-days (time-add (current-time) (list 0 86400 0))))))
("key" "description" entry (file+function "path/to/file" datetree-tomorrow)
"%?")