I have just started to use org-mode and I am tweaking an existing configuration to my needs.
In that configuration, the code is itself in an org file and the org-capture-templates is splited in a lot of individual blocks (because there are some text explanations between) like
(add-to-list 'org-capture-templates
'("j" "Journal entry"
entry
(file+datetree "~/org/journal.org")
"* %?"
:empty-lines 1
))
Given that I have defined my org-directory to "~/org" and that this path is duplicated in quite every entry definition, in case I would move the org file in say a share or a git repo, I tried to replace the file paths by a construct like
(add-to-list 'org-capture-templates
'("j" "Journal entry"
entry
(file+datetree (concat org-directory "/journal.org"))
"* %?"
:empty-lines 1
))
Unfortunately when I try to capture a journal entry I get this
org-capture-expand-file: Invalid file location: nil
while (concat org-directory "/journal.org") evaluates to the same value "~/org/journal.org". I suppose that the concat is missing some quoting, but I did no find the correct form.
backquoteinstead ofquotein front of the entry and precede the(concat ...form with a comma. That will quote the rest of the entry, but it will evaluate the expression after the comma. See Backquote in the Emacs Lisp Reference manual. – NickD May 10 '23 at 01:34backquote, you can find a bunch of different manifestations of the same underlying problem (quotequotes everything, so nothing gets evaluated in the quoted expression;backquotequotes everything except it allows evaluation of selected sub-expressions). After having seen a few, you get to recognize the underlying problem. – NickD May 10 '23 at 15:18