1

I'm trying to create an org capture template that will just insert a second level point: "** 2021/07/16" (or whatever the current date is).

I expect this setq example to do that:

  (setq org-capture-templates
                '(
                  ("d" "Daily" entry (file "~/notes/daily.org") "** %Y/%m/%d %?")))

However what it inserts instead is:

* %Y/%m/%d

(first level point instead of second level, and the literal %Y etc instead of the date)

This is based on (probably a poor) reading of org-capture examples with slight adjustment. I have at most a basic understanding of org mode and emacs so please feel free to explain any principles that I've missed.

I'm also using spacemacs, in case that is relevant. This setq command is inside my defun dotspacemacs/user-config.

3

org-capture-templates probably has the densest doc-string of any variable. The way I deal with it is figure out what I need to do, do it once and then never change it :-) The downside is that when I need to change it, I find that I've forgotten everything so I need to start from scratch. But after doing it a dozen times or so, the relearning gets faster and easier. In short, hang in there!

For the time stamp, you can either use %t which provides the date in ISO format, or you can use %<%Y/%m/%d> as the doc string of org-capture-templates describes:

%<...> The result of format-time-string on the ... format specification.

The level at which the capture is entered for an entry type is again described in the doc string:

... Will be filed as the child of the target entry or as a top-level entry.

Since you are not using a target entry, it is filed as a top-level entry, no matter how many stars you put in the template. See the target description in the doc string.

You could create a top-level headline, say * My daily thoughts in your file and then use

  ... (file+headline "~/notes/daily.org" "My daily thoughts") ...

instead of the plain file entry: the captures would end up under that headline.

There is plenty more in the doc string to keep you busy for a while. Start simple, experiment, ask questions: you'll get there.

BTW, to get the doc string of the variable, do

C-h v org-capture-templates

and if you don't know yet how to use the emacs help system, do C-h ? and learn how to use it ASAP!

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.