10

I was configuring some capture templates for org mode but when adding any new template to init file, the default TASK template disappeared.

 (setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/org/refile.org" "Tasks")
             "* TODO %t %?\n ")
        ("n" "Note" entry (file+headlin "~/org/notes.org")
             "* %?\nEntered on %U\n  %i\n  %a")))

The issue is that when adding any other template, option default for tasks disappeared, but if I add a default task template, some of the expansions for template I like a lot, such as link to file or date of addition I've managed to emulate but no success so far.

where is default template code located?

3
  • 1
    Using setq will overwrite anything bound to that variable. Try using push or add-to-list instead.
    – Dan
    Commented Dec 28, 2018 at 12:26
  • @Dan Actually that won't work - the default templates aren't stored in the variable, they're hard-coded as a fall-back that is only available when the actual value of org-capture-templates is nil. Which is a bit counter-intuitive to me.
    – Tyler
    Commented Dec 28, 2018 at 15:08
  • @Tyler : weird, but then there’s a lot of weird stuff under the hood in the org mode source.
    – Dan
    Commented Dec 28, 2018 at 15:45

1 Answer 1

12

The default capture templates are only available if you haven't set a value fororg-capture-templates, which means @Dan's suggestion of using add-to-list won't work in this case. If you want to continue using the default tasks template in addition to your own templates, you need to add it explicitly. It takes a bit of digging to find it, hidden in the code of the function org-capture-select-template:

 '(("t" "Task" entry (file+headline "" "Tasks")
    "* TODO %?\n  %u\n  %a"))

In your case, you'll need something like the following:

(setq org-capture-templates
     '(("t" "Todo" entry (file+headline "~/org/refile.org" "Tasks")
            "* TODO %t %?\n ")
       ("n" "Note" entry (file+headlin "~/org/notes.org")
            "* %?\nEntered on %U\n  %i\n  %a")
       ("T" "Task" entry (file+headline "" "Tasks")
            "* TODO %?\n  %u\n  %a")))

Note that I used a capital T to distinguish it from your Todo entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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