Daniel Schoepe <dan...@schoepe.org> 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