From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Looking for a sample function to find a location for org-capture Date: Thu, 12 Aug 2010 07:42:40 -0400 Message-ID: <8214.1281613360@gamaville.dokosmarshall.org> References: <7D5F4098-7222-4B24-B52E-60A00E576130@gmail.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=32874 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjWBT-0000oZ-3V for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 07:42:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjWBR-0007Lm-TL for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 07:42:54 -0400 Received: from vms173009pub.verizon.net ([206.46.173.9]:58540) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjWBR-0007LU-QF for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 07:42:53 -0400 Received: from gamaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173009.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0L71004OKF74CI80@vms173009.mailsrvcs.net> for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 06:42:41 -0500 (CDT) In-reply-to: Message from Carsten Dominik of "Thu, 12 Aug 2010 12:06:10 +0200." <7D5F4098-7222-4B24-B52E-60A00E576130@gmail.com> 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: Carsten Dominik Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org, Charles Cave Carsten Dominik wrote: > > On Aug 12, 2010, at 3:30 AM, Charles Cave wrote: > > > I'm exploring the many features of org-capture and I see the > > documentation about a function for finding the location for refiling. > > What exactly are you referring to? > > > > > I would like to see some sample code on how to do this. > > > > At the moment I am using a date tree to file my TODO items and > > notes. (I am writing an article about this and will publish soon) > > > > Let's say I had a headline structure for weeks of the year and I would > > like a function to add an item to the heading corresponding to the > > week > > of the year. Today (12th Aug) we are in Week 32. > > > > What would the function be to file under the appropriate heading: > > > > * 2010 > > ** 2010-Week-28 > > ** 2010-Week-29 > > ** 2010-Week-30 > > ** 2010-Week-31 > > ** 2010-Week-32 > > ** 2010-Week-33 > > > > Could the function create the heading if it didnt exist . just like > > org-capture handles creation of new brances on a date tree? > > Well, the datetree is a special library that does create the > headings for a date tree. If you want a different structure > (weeks instead of months), code for this would have to be written, and > I guess org-capture would have to be extended to call this code. > But I am not sure if I understand what you are asking. > I think Charles is referring to the following in org-capture-templates's doc string: ,---- | (file+function "path/to/file" function-finding-location) | A function to find the right location in the file | | ... | | (function function-finding-location) | Most general way, write your own function to find both | file and location `---- I tried using the first (in a very simple minded way) but it was late last night, I was tired and I couldn't get it to work in five minures, so I gave up: (WARNING: DOES NOT WORK) ,---- | (setq org-capture-templates | '(... | ("X" "Experimental function for Charles Cave" entry (file+function "~/lib/org/charles.org" cc-date-tree) "* DONE %? | %U %a" :prepend t) | ... | )) | | (defun cc-date-tree () | (let ((year 2010) | (weeknum 32)) | (format "%4d-Week-%2d" year weeknum))) `---- (WARNING: DOES NOT WORK) So maybe I have it completely wrong, maybe this is close, but at this point I just don't know. Also, I saw in the doc string the following: ,---- | (file+datetree "path/to/file") | Will create a heading in a date tree `---- which might do exactly what Charles wants in this case, without having to write a function? But I have no idea how datetrees work, so this too might be off. Thanks, Nick