Thanks for the note.  I did indeed mean to use headings.

I think it would be nice to be able to have the file dynamic but the heading 
static in capture templates.  In my case, I always want to find a particular 
heading in the buffer that the capture originated from. So I had to put the 
whole target spec in a function, as in:

   (setq org-capture-templates
      `(("t" "Todo (local)" entry
         (function (lambda ()
                     (set-buffer (org-capture-get :original-buffer))
                     (let ((hd "Tasks"))
                       (goto-char (point-min))
                       (if (re-search-forward
                            (format org-complex-heading-regexp-format 
(regexp-quote hd))
                            nil t)
                           (beginning-of-line 2)
                         (goto-char (point-max))
                         (or (bolp) (insert "\n"))
                         (insert "* " hd "\n")
                         (beginning-of-line 0)))))

most of which is copied from the file+heading case in org-capture.el

What I'd like to be able to write in an org-capture-template is something like:

   (setq org-capture-templates
      `(("t" "Todo (local)" entry 
             (lambda () (org-capture-get :original-buffer))

Where the function sets the buffer, but org machinery is used to match the 

Another idiom would be to allow a string-returning function wherever a string 
is currently allowed for the file target, so the above would be instead:

   (setq org-capture-templates
      `(("t" "Todo (local)" entry 
             (lambda () (org-capture-get :original-buffer))

The last is my preferred, as it would apply to all of the "file+headline", 
"file+olp", "file+regexp", etc. target specifications in allowed for 


-- Greg
Greg Sullivan
(781)262-4553 (office) (978)430-3461 (cell)

-----Original Message-----
From: Giovanni Ridolfi [] 
Sent: Thursday, December 23, 2010 6:42 AM
To: Sullivan, Gregory (US SSA)
Subject: Re: [Orgmode] using (id "Name") target in org-capture-templates

"Sullivan, Gregory (US SSA)" <> writes:

> I would like to have a template that will add a TODO below the "Tasks"
> heading in the current .org file.  From the documentation, I would
> think that 
> (setq org-capture-templates
>       `(("t" "Todo (local)" entry (id "Tasks")
>        "* TODO %? %i\n%T\n" :prepend t)
>  ))
> would work, 

Be careful: "heading" is not "id".

from the documentation of the variable in the file org-mode/lisp/org-capture.el

   target: (id \"id of existing org entry\")
                  File as child of this entry, or in the body of the entry

Do you have a tree like the following?

* Tasks
   :ID: Tasks            

If yes, then it works, if the :ID: value is unique.


Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.

Reply via email to