I use emacs on a few different machines which unfortunately don't have the same file structure, but I want to share my config among them as much as possible. All machines have a ".../org/" folder which is synchronized with syncthing. I want to set up my capture templates to build their target file paths from a variable set per-machine which points to that org folder, instead of manually editing each template's target to be the full path to each file.
I have put this code in my init.el:
(setq lk/org-file-path "~/../../Documents/org/")
(setq org-capture-templates
'(("t" "tasks / Projects")
("tt" "task" entry (file+olp (concat lk/org-file-path "Tasks.org") "Inbox")
"* TODO %?\n %U\n %a\n %i" :empty-lines 1)
...
))
Trying to capture with this template gives the error "Invalid file location: nil". But running (concat lk/org-file-path "Tasks.org")
in scratch results in "~/../../Documents/org/Tasks.org", and putting that string in place of the concat in the template definition allows the template to successfully run and save my input in the correct file.
How can I work around this?