emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Daniel Schoepe <daniel@schoepe.org>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Dynamically generating todo entries
Date: Wed, 02 Nov 2011 19:11:38 -0400	[thread overview]
Message-ID: <6130.1320275498@alphaville.americas.hpqcorp.net> (raw)
In-Reply-To: Message from Daniel Schoepe <daniel@schoepe.org> of "Wed, 02 Nov 2011 22:27:08 BST." <87obwu8bbn.fsf@gilead.invalid>

Daniel Schoepe <daniel@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

  reply	other threads:[~2011-11-02 23:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 21:27 Dynamically generating todo entries Daniel Schoepe
2011-11-02 23:11 ` Nick Dokos [this message]
2011-11-02 23:35   ` Daniel Schoepe
2011-11-03 10:49     ` Jonas Hörsch
2011-11-23 16:41     ` suvayu ali
2011-11-23 17:17       ` Daniel Schoepe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6130.1320275498@alphaville.americas.hpqcorp.net \
    --to=nicholas.dokos@hp.com \
    --cc=daniel@schoepe.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).