I've been trying to setting the capture configuration for org-mode, however, when I try to select a capture template, I get this message:

Template key: 
byte-code: Capture template `p': listp

Here is my conf:

       (setf org-footnote-auto-adjust t
             org-directory (expand-file-name "~/org")
             org-archive-location (concat org-directory "/archivado.org::* Entradas viejas y archivadas")
             ;; ...
             org-agenda-files (list (concat org-directory "/trabajo.org")
                                    (concat org-directory "/notas.org")
                                    (concat org-directory "/otros.org")
                                    (concat org-directory "/agenda.org"))
             org-log-done 'time
             org-default-notes-file (concat org-directory "/notas.org")
             org-capture-templates '(("p" "Cosas por hacer" entry (file+headline (concat org-directory "/otros.org") "Tareas")
                                      "* Tareas %?\n  %i\n  %a")
                                     ("d" "Diario" entry (file+datatree (concat org-directory "/diario.org"))
                                      "* %?\nInsertado el %U\n  %i\n  %a")
                                     ("a" "Apuntes importantes" entry (file+datatree "")
                                      "* Notas importantes %?\nNota importante del %U\n  %i\n  %a")
                                     ("g" "Agenda" entry (file+datatree+prompt (concat org-directory "/agenda.org"))
                                      "* Agenda %?\n Ingresado el %T\nProgramado para el %:date\n  %i\n"))
             org-clock-persist 'history)

       ;; ...
       (define-key global-map (kbd "C-c c") 'org-capture)

If I press a I get this error:

Template key: 
org-capture-set-target-location: Invalid capture target specification

But according to the manual this (file+datatree "") should be valid, what I'm missing?

  • 1
    Could you provide a shorter working example? Most of these configs are unrelated, and some quick testing should be enough to tell you which parts are relevant. – Malabarba Oct 8 '14 at 7:25
  • I though one could just copy and paste unto *scratch* buffer, evaluate the buffer and try to reproduce the issue, and I included the entire org-mode conf because I though it was convenient than not including something that may be causing this problem! – shackra Oct 9 '14 at 0:00
  • 1
    What version of org are you using? I don't see file+datatree in it. I see file+datetree. – seth Oct 9 '14 at 5:50
  • Org-mode version 8.2.8 (8.2.8-elpa @ /home/jorge/.emacs.d/elpa/org-20141006/). I corrected that misspell in my conf, thanks! I still get the Capture template p': listp` thing and with "Agenda" and "Diario" I get org-capture-set-target-location: Invalid capture target specificationthough... – shackra Oct 9 '14 at 6:19
  • @JorgeArayaNavarro yes, we can paste and eval the whole thing. And the next thing we'll do is gradually remove parts of it until the bug disappears. :-) I'm just saying you'll get help faster if you do the second part yourself (gradually reduce the config, until you find which part causes the problem, and post that part). Of course, that's goes not just for this site, but anywhere on the internet people will always ask you for a minimal working example. – Malabarba Oct 9 '14 at 7:04

Your issue is that the valid specification is file+datetree and you have file+datatree.

This is true for your Diario,Apuntes importantes and Agenda. If you correct that one spelling mistake it will allow them to resolve properly.

Tested this with emacs -q, adding current org to the load path, requiring it then evaluating the setf. It no longer gave errors (other than directory not already existing since I use ~/documents/org instead of ~/org.

| improve this answer | |
  • really? because I make the corrections, saved the file, closed emacs, opened it again, pressed <kbd>C-c</kbd><kbd>c</kbd> and I still get those annoying byte-code: Capture template g': listp. This is without removing anything from my org-mode configuration. Tomorrow I'll try again just letting the org-capture-templates` defined in my conf. My org-mode version is Org-mode version 8.2.8 (8.2.8-elpa @ /home/jorge/.emacs.d/elpa/org-20141006/) what's yours? – shackra Oct 10 '14 at 5:58
  • My Lord and my God, it works if I comment almost everything in my org-mode conf except what I said I wouldn't comment. I did a quick test, commenting everything again and uncommenting it line per line until I hit the issue. The problem is with org-blank-before-new-entry t in my configuration, I don't know exactly why, but commenting it and uncommenting the rest don't make this issue happens again. btw, which answer should I mark as correct? Should I better answer myself? – shackra Oct 10 '14 at 6:21

You've got this:

'(("p" "Cosas por hacer" entry (file+headline (concat org-directory "/otros.org") "Tareas") ...

but the concat part won't get evaluated: a string is expected after file+headline, and you've provided a list, hence the error. Try the following instead: (note the backquote)

`(("p" "Cosas por hacer" entry (file+headline ,(concat org-directory "/otros.org") "Tareas") ...

To see the difference in result, you can play about evaluating those two expressions by placing the cursor after them and using C-x C-e.

P.S. Prefer expand-file-name to concat when joining directory and filenames to make a path.

| improve this answer | |
  • 1
    Actually, I think there's a second problem. This throws an error upon saving the template, he is getting (the listp p thing) an error upon first invoking the capture (I tested his config and the error does indeed happen). – Malabarba Oct 8 '14 at 7:23
  • Yup. these changes didn't solved the issue! – shackra Oct 8 '14 at 23:58
  • Back quoting isn't needed in this case, he's using setf rather than setq. – Jonathan Leech-Pepin Oct 9 '14 at 11:12
  • @Jonathan That won't make a difference. If you pass a quote to setf, it's not suddenly going to start looking inside it and evaluating parts of it. If the set data is to contain the result of the concat, which was my assumption, then the above is correct. If org-agenda itself actually evaluates the (concat ...) form, then this will of course be unnecessary. – sanityinc Oct 9 '14 at 12:31
  • Oops, missed that logic. However there is something odd. In past incarnations I know I had had to backquote-expand certain elements in org-capture templates and org-agenda templates to get them to work properly, but with his example they properly expanded to ~/org/otros.org when attempting the capture. – Jonathan Leech-Pepin Oct 9 '14 at 12:36

So, after following the advices posted here, and doing some debugging, I found out that my issue was caused by the line (setf org-blank-before-new-entry t), commenting it enabled me to capture annotations.

| improve this answer | |

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.