emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sullivan, Gregory (US SSA)" <gregory.sullivan@baesystems.com>
To: Giovanni Ridolfi <giovanni.ridolfi@yahoo.it>
Cc: "Emacs-orgmode@gnu.org" <Emacs-orgmode@gnu.org>
Subject: RE: using (id "Name") target in org-capture-templates
Date: Thu, 6 Jan 2011 11:54:44 -0500	[thread overview]
Message-ID: <E1Pat6u-0007o6-QM@eggs.gnu.org> (raw)
In-Reply-To: <83d3osbtrx.fsf@yahoo.it>

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          gregory.sullivan@baesystems.com
(781)262-4553 (office) (978)430-3461 (cell)

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

"Sullivan, Gregory (US SSA)" <gregory.sullivan@baesystems.com> 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	other threads:[~2011-01-06 16:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-22 19:33 using (id "Name") target in org-capture-templates Sullivan, Gregory (US SSA)
2010-12-23 11:41 ` Giovanni Ridolfi
2011-01-06 16:54   ` Sullivan, Gregory (US SSA) [this message]
2011-02-11 10:21     ` Bastien
2011-02-12 18:09       ` [Accepted] " Bastien Guerry
2011-02-22 18:55       ` Sullivan, Gregory (US SSA)
2011-02-27 11:37         ` Bastien
2011-02-28  1:38           ` Sullivan, Gregory (US SSA)
     [not found] <20110228040226.9CDE5EADE@mx.altern.org>
2011-03-06 17:08 ` Bastien
2011-03-06 19:57   ` Sullivan, Gregory (US SSA)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Pat6u-0007o6-QM@eggs.gnu.org \
    --to=gregory.sullivan@baesystems.com \
    --cc=Emacs-orgmode@gnu.org \
    --cc=giovanni.ridolfi@yahoo.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).