I am attempting to use the org-roam dailies capture templates to insert entries underneath a headline specified by the an org-roam-dailies-capture-templates key. I was hoping to get it to look something like this:
* 2022-09-25 Sunday
** logs
*** 20:00 Log Entry 01
This is a log entry
*** 23:00 Log Entry 02
This is also a log entry
** reflections
*** 22:00 Reflection Entry 01
This is a reflection entry
*** 23:30 Reflection Entry 02
This is also a reflection entry
So I tried to do this the way I would with org-capture-templates
, by using a custom function with the :target
property to move point to the respective headline and then insert my entry. However, it seems that org-roam-capture-templates
and org-roam-dailies-capture-templates
don’t accept the same arguments as regular org-capture-templates
. In particular, custom functions to move the point within the file are not supported as far as I can tell.
A sample of the code that I hoped would achieve my purpose is
org-roam-dailies-capture-templates
("l" "log entry" entry
"* %<%H:%M>\n%?"
:target (file+function "%(expand-file-name "%<%Y-%m>.org" org-roam-dailies-directory"
(function organum-capture-journal-target-heading))
:journal-type "logs")
and the untested function to move to the heading is
(defun organum-capture-journal-target-heading ()
"Return a file target for a journal capture."
(let ((date-heading (format-time-string "%Y-%m-%d %A"))
(journal-heading (org-capture-get :journal-type)))
(goto-char (point-min))
(if (re-search-forward
(format org-complex-heading-regexp-format
(regexp-quote date-heading))
nil t)
(beginning-of-line)
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "* " date-heading "\n")
(beginning-of-line 0))
(if (re-search-forward
(format org-complex-heading-regexp-format
(regexp-quote journal-heading))
nil t)
(beginning-of-line)
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "* " journal-heading "\n")
(beginning-of-line 0))))
i am not sure the above function works, but it hopefully captures the idea of what I am attempting to do. Is there any way for me to achieve this with org-roam’s capture templating system?