From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sullivan, Gregory (US SSA)" Subject: RE: using (id "Name") target in org-capture-templates Date: Thu, 6 Jan 2011 11:54:44 -0500 Message-ID: References: <83d3osbtrx.fsf@yahoo.it> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=52774 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pat6w-0003It-17 for Emacs-orgmode@gnu.org; Thu, 06 Jan 2011 11:54:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pat6u-0007o6-QM for Emacs-orgmode@gnu.org; Thu, 06 Jan 2011 11:54:49 -0500 Received: from dmzms99901.na.baesystems.com ([149.32.200.65]:11738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pat6u-0007ny-OE for Emacs-orgmode@gnu.org; Thu, 06 Jan 2011 11:54:48 -0500 In-Reply-To: <83d3osbtrx.fsf@yahoo.it> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Giovanni Ridolfi Cc: "Emacs-orgmode@gnu.org" 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 headin= g static in capture templates. In my case, I always want to find a particu= lar 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 l= ike: (setq org-capture-templates `(("t" "Todo (local)" entry=20 (function+heading=20 (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 stri= ng is currently allowed for the file target, so the above would be instead: (setq org-capture-templates `(("t" "Todo (local)" entry=20 (file+heading=20 (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-ca= pture-templates. Thanks. -- Greg --=20 Greg Sullivan gregory.sullivan@baesystems.com (781)262-4553 (office) (978)430-3461 (cell) -----Original Message----- From: Giovanni Ridolfi [mailto:giovanni.ridolfi@yahoo.it]=20 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)" 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=20 > > (setq org-capture-templates > `(("t" "Todo (local)" entry (id "Tasks") > "* TODO %? %i\n%T\n" :prepend t) > )) > > would work,=20 Be careful: "heading" is not "id". from the documentation of the variable in the file org-mode/lisp/org-captur= e.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 =20 :END: If yes, then it works, if the :ID: value is unique. cheers, Giovanni