4

I am trying to use concat from within an org-capture template. But I keep getting an "Invalid template" error, so something's not right. Here is my code:

(setq org-capture-templates
    '(("j" "Journal" entry (file+datetree "~/org/journal.org")
      (concat "* " (format-time-string "%H:%M") " %^{Title}\n\n%?"))))

Any ideas?

5

Okay, figured it out! Because the template was quoted '(("j"... the concat expression was not being evaluated. What I needed to do was use backquote and then insert a , before the concat statement to allow this part to evaluate:

(setq org-capture-templates
    `(("j" "Journal" entry (file+datetree "~/org/journal.org")
      ,(concat "* " (format-time-string "%H:%M") " %^{Title}\n\n%?"))))
0

If you use concat, it seems to not update the timestamp for each entry. You can use the built in template expansion for time to make it use the current time when you capture, rather than the time the configuration file was read.

(setq org-capture-templates
    '(("j" "Journal" entry (file+datetree "~/org/journal.org")
      "* %<%H:%M> %^{Title}\n\n%?")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.