From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: Define capture template with dynamic id target Date: Fri, 10 Jun 2011 12:50:50 -0300 Message-ID: <4df23d66.814de50a.09ad.7325@mx.google.com> References: <4df10e5c.4b6edc0a.1d4f.1a14@mx.google.com> <87aadqjlq8.wl%dmaus@ictsoc.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([140.186.70.92]:49087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QV3zI-00029g-2A for emacs-orgmode@gnu.org; Fri, 10 Jun 2011 11:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QV3zF-0006DZ-DP for emacs-orgmode@gnu.org; Fri, 10 Jun 2011 11:51:07 -0400 Received: from mail-qw0-f41.google.com ([209.85.216.41]:40547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QV3zE-0006DI-Vs for emacs-orgmode@gnu.org; Fri, 10 Jun 2011 11:51:05 -0400 Received: by qwa26 with SMTP id 26so1895715qwa.0 for ; Fri, 10 Jun 2011 08:51:03 -0700 (PDT) In-Reply-To: <87aadqjlq8.wl%dmaus@ictsoc.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: David Maus Cc: Orgmode Mailing List Thanks David, I tried to follow your suggestion, but I found two problems (maybe because I know little about lisp). For instance, suppose I have a test.org file with the follow content --8<---------------cut here---------------start------------->8--- * 2011 Every headline has an ID, but I have omitted here for brevity *** May ***** Sub-headline bla bla bla *** June ***** Sub-headline bla bla bla --8<---------------cut here---------------end--------------->8--- I want the capture process to add an entry to the Sub-headline of June. If I just use the file+headline and specify "Sub-headline" then it will add to the Sub-headline in May. That's why I tried using IDs in the first place. Also, every month I create a new month headline with the Sub-headline and the capture process should add an entry to that instead. That is the reason I wanted to get the ID from a function, instead of just writing it in the capture template. As far as I understand if I use the file+function target then the function must return the headline name, but how can I say that I want the Sub-headline of June and not of May? [first problem] I found an org-id-find function that returns something like "(filename . characterPosition)". Therefore, If there is a way to specify a position where org should start looking for the headline then I could use that to go to the correct Sub-headline. Also, the file+headline target will add the entry as a child of the specified headline, but file+function seems to add the entry as a sibling of the headline returned by the function. [second problem] Is this intended behaviour or is it a bug? -- Thanks again, Darlan At Fri, 10 Jun 2011 07:31:43 +0200, David Maus wrote: > > [1 ] > At Thu, 09 Jun 2011 15:18:00 -0300, > Darlan Cavalcante Moreira wrote: > > > > > > Hello List, > > > > I'm trying to create a few templates for org capture and I have found a > > weird behavior with the ID target type. It works OK if I use the ID > > directly like below > > #+begin_src emacs-lisp > > (id "Junho2011Contas") > > #+end_src > > but it does not find the ID if I try to get it from a function, such as > > #+begin_src emacs-lisp > > (id (get-me-an-org-id-for-the-month "Contas")) > > #+end_src > > Org capture does not support executing a function in the ID target spec. > > C-h v org-capture-templates RET > > target Specification of where the captured item should be placed. > In Org-mode files, targets usually define a node. Entries will > become children of this node, other types will be added to the > table or list in the body of this node. > > Most target specifications contain a file name. If that file > name is the empty string, it defaults to `org-default-notes-file'. > A file can also be given as a variable, function, or Emacs Lisp > form. > > Valid values are: > > (file "path/to/file") > Text will be placed at the beginning or end of that file > > (id "id of existing org entry") > File as child of this entry, or in the body of the entry > > ... > > You might use the `function' target spec > > (function function-finding-location) > Most general way, write your own function to find both > file and location > > HTH, > -- David > -- > OpenPGP... 0x99ADB83B5A4478E6 > Jabber.... dmjena@jabber.org > Email..... dmaus@ictsoc.de > [2 ] >