Reputation: 1314
I'm using org-mode and trying to set up a capture template to put a TODO under a heading named by the current date. For example, for today (12/12/12), my heading would be:
*** Dec 12
So I have tried this in my template:
'(org-capture-templates (quote
(
;;; note: this template works
("d" "Defect" entry (file+headline "~/doc/org/defects.org" "Open") "** TODO %^{Defect}")
;;; this template does not
("t" "Todo" entry (file+headline "~/doc/org/timesheet.org" (format-time-string "%h %e")) "**** TODO %i%?"))))
However, I get a wrong-type-argument stringp
exception. Here's a bit of the stacktrace:
Debugger entered--Lisp error: (wrong-type-argument stringp (format-time-string "%h %e"))
regexp-quote((format-time-string "%h %e"))
(format org-complex-heading-regexp-format (regexp-quote hd))
(re-search-forward (format org-complex-heading-regexp-format (regexp-quote hd)) nil t)
(if (re-search-forward (format org-complex-heading-regexp-format ...) nil t) (goto-char (point-at-bol)) (goto-char (point-max)) (or (bolp) (insert "\n")) (insert "* " hd "\n") (beginning-of-line 0))
... snip ...
I have a feeling it's more of a generic Emacs Lisp issue rather than an org-mode question but I'm not sure what it could be. I ran across a post (I cannot find it again) that said something to the effect that by putting format-time-string into parenthesis, Lisp didn't see it as a string. Which seems true enough because if I evaluate it, nothing is printed unless I do an insert. But I don't want to insert it - I want the expression to be evaluated and used as a string. Another question has me thinking similarly, that I have to do something to get the formatted string to appear as a string.
Upvotes: 1
Views: 1337
Reputation: 29021
It seems there is too much quoting and the call is never evaluated. As you said, a string works, so you could try to change that inside quote
to a quasi-quote and a comma. Also, looking at the format, it seems that this variable is a list of lists, and you have a list of lists of lists. My guess is this:
`(org-capture-templates (
("t" "Todo" entry (file+headline "~/doc/org/timesheet.org" ,(format-time-string "%h %e")) "**** TODO %i%?")))
I'm not aware of the templating format, but you have to be sure the function call is evaluated to produce the actual list with the values evaluated.
Upvotes: 1