From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Dynamically generating todo entries Date: Wed, 02 Nov 2011 19:11:38 -0400 Message-ID: <6130.1320275498@alphaville.americas.hpqcorp.net> References: <87obwu8bbn.fsf@gilead.invalid> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLjyJ-0002rr-Uh for emacs-orgmode@gnu.org; Wed, 02 Nov 2011 19:11:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLjyI-0004ov-Cp for emacs-orgmode@gnu.org; Wed, 02 Nov 2011 19:11:51 -0400 Received: from g6t0185.atlanta.hp.com ([15.193.32.62]:37970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLjyI-0004mR-9E for emacs-orgmode@gnu.org; Wed, 02 Nov 2011 19:11:50 -0400 In-Reply-To: Message from Daniel Schoepe of "Wed, 02 Nov 2011 22:27:08 BST." <87obwu8bbn.fsf@gilead.invalid> 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: Daniel Schoepe Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Daniel Schoepe wrote: > Hello, > > I'm trying to dynamically generate a list of TODO entries (specifically, > a list of notmuch[1] threads that have a "todo" tag) that I'd like to > see in the TODO agenda, but not in the normal daily agenda (just like a > ordinary TODO entry without a date). A simple try like > > (defun foo () > "Test function" > "TODO foo") > -- > in something.org: > %%(foo) > > ends up generating an entry for every day in the weekly/daily agenda, > but this entry is not recognized as a TODO entry. Is %%(foo) (I don't > know the actual name of this feature) the wrong mechanism for my goal? > If so, is there an alternative for accomplishing what I had in mind? > They are generally called (somewhat misleadingly) diary sexps - they are executed by org-agenda-get-sexps (assuming that they are in some agenda file) when the agenda is constructed, once for every day displayed: they do their things and that's that. They are mostly used to remind one of birthdays, anniversaries etc, hence diary sexps. > By the way: Is there a resource describing what special variables are > available to such functions (I only know about date) and how their > output should look like? I couldn't find anything in the org manual. > What do you mean by special variables? Any variable in the dynamic chain is fair game: date is available because a caller (org-agenda-list) goes to the trouble of binding it. Any other variable in this function or in any parent of org-agenda-get-sexps can be used (unless it's shadowed), but I'm not sure what use they would be. The function just has to return a string: the agenda code takes care of printing the result in the agenda. > [1] http://notmuchmail.org > Diary sexps is probably the wrong thing to use for what you want: I don't know how far you want to take it, but iiuc, the easiest thing to do is write a script (in your favorite language) that generates a file of entries, say foo.org: ,---- | | * notmuch threads | | ** TODO check out this thread [[some link][thread title]] | ** TODO check out that thread [[some other link][other thread title]] | ... `---- Then open it in emacs and include it in your agenda with C-c [ HTH, Nick