emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Orgmode] using (id "Name") target in org-capture-templates


From: Sullivan, Gregory (US SSA)
Subject: RE: [Orgmode] using (id "Name") target in org-capture-templates
Date: Thu, 6 Jan 2011 11:54:44 -0500

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 
         (function+heading 
             (lambda () (org-capture-get :original-buffer))
             "Tasks"))
     ...

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

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 
         (file+heading 
             (lambda () (org-capture-get :original-buffer))
             "Tasks"))
     ...

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 
org-capture-templates.

Thanks.

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

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

"Sullivan, Gregory (US SSA)" <address@hidden> 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
   :PROPERTIES:
   :ID: Tasks            
:END:

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

cheers,
Giovanni



reply via email to

[Prev in Thread] Current Thread [Next in Thread]