0

I am new to org-mode (and to Emacs in general) and am trying to set up org-capture. I would like to define a todo capture item whose template is located in the file ~/.emacs.d/org-templates/todo.tmpl. I have tried with

(global-set-key (kbd "C-c c") 'org-capture)

(setq org-directory "~/org/")
(setq org-default-notes-file (concat org-directory "notes.org"))
(setq org-todo-template (concat user-emacs-directory "org-templates/todo.tmpl"))


(setq org-capture-templates
      '(("t"
         "Todo list item"
         entry
         (file+headline org-default-notes-file "Tasks")
         (file org-todo-template)
        )))

I get the error:

Wrong type argument: stringp, org-todo-template

if I replace the line

         (file org-todo-template)

with

         (file "~/.emacs.d/org-templates/todo.tmpl")

then it works, and I do not understand why.

For reference, the content of the file ~/.emacs.d/org-templates/todo.tmpl is

* TODO %^{Description}
  %i
  %a
  - %?
  :LOGBOOK:
  CREATED: %U
  :END:
Kristian
  • 103
  • 2
  • This is a FAQ, although finding the duplicates is not easy if you don't know the answer already: search for `backquote`. – NickD Feb 07 '21 at 23:04
  • 1
    @NickD: Yes, this did solve my problem. I searched for all sort of things, but being new to Emacs, I did not exactly now what to search for. Thanks. – Kristian Feb 09 '21 at 06:28

1 Answers1

1

Try this:

(setq org-capture-templates
      `(("t"
         "Todo list item"
         entry
         (file+headline org-default-notes-file "Tasks")
         (file ,org-todo-template)
        )))

The backquote quotes the list but allows the , to interpolate the value of the variable org-todo-template.

Fran Burstall
  • 3,665
  • 10
  • 18