all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Dynamically generating todo entries
@ 2011-11-02 21:27 Daniel Schoepe
  2011-11-02 23:11 ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schoepe @ 2011-11-02 21:27 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

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?

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.

[1] http://notmuchmail.org

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamically generating todo entries
  2011-11-02 21:27 Dynamically generating todo entries Daniel Schoepe
@ 2011-11-02 23:11 ` Nick Dokos
  2011-11-02 23:35   ` Daniel Schoepe
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2011-11-02 23:11 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: nicholas.dokos, emacs-orgmode

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamically generating todo entries
  2011-11-02 23:11 ` Nick Dokos
@ 2011-11-02 23:35   ` Daniel Schoepe
  2011-11-03 10:49     ` Jonas Hörsch
  2011-11-23 16:41     ` suvayu ali
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Schoepe @ 2011-11-02 23:35 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]

On Wed, 02 Nov 2011 19:11:38 -0400, Nick Dokos <nicholas.dokos@hp.com> wrote:
> 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.

Ah, okay. Thanks.

> > 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.

I was just wondering if there is a listing of such variables specific to
org and explicitly intended to be used by diary sexps (i.e. not an
implementation detail that might change without warning).

> The function just has to return a string: the agenda code takes care
> of printing the result in the agenda.

Okay, I guess their simplicity explains why I couldn't find more
information on them in the manual.

> 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 [

Now that you mention it, this is a perfectly obvious solution. :)

By advising (there does not seem to be a hook for that) `org-todo-list'
I can even avoid running that script in a cronjob and thus not allowing
the agenda to become out of sync with the actual notmuch tags.

Thank you for your time and your answers.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamically generating todo entries
  2011-11-02 23:35   ` Daniel Schoepe
@ 2011-11-03 10:49     ` Jonas Hörsch
  2011-11-23 16:41     ` suvayu ali
  1 sibling, 0 replies; 6+ messages in thread
From: Jonas Hörsch @ 2011-11-03 10:49 UTC (permalink / raw)
  To: emacs-orgmode

[fn:1]

Footnotes:

[fn:1] Mail

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamically generating todo entries
  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
  1 sibling, 1 reply; 6+ messages in thread
From: suvayu ali @ 2011-11-23 16:41 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: nicholas.dokos, emacs-orgmode

On Thu, Nov 3, 2011 at 00:35, Daniel Schoepe <daniel@schoepe.org> wrote:
>> 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 [
>
> Now that you mention it, this is a perfectly obvious solution. :)

You can take pointers from here:
<http://orgmode.org/worg/org-hacks.html#sec-3-12>

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Dynamically generating todo entries
  2011-11-23 16:41     ` suvayu ali
@ 2011-11-23 17:17       ` Daniel Schoepe
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Schoepe @ 2011-11-23 17:17 UTC (permalink / raw)
  To: suvayu ali; +Cc: nicholas.dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

On Wed, 23 Nov 2011 17:41:49 +0100, suvayu ali <fatkasuvayu+linux@gmail.com> wrote:
> You can take pointers from here:
> <http://orgmode.org/worg/org-hacks.html#sec-3-12>

Yeah, I figured out a solution that works for me:

(defadvice org-todo-list (before org-todo-gen-notmuch activate)
  (let ((buf (get-file-buffer "~/org/notmuch_todo.org")))
    (when buf
      (kill-buffer buf)))
  (call-process "notmuch-org"))

(Together with a not very interesting python script that generates
notmuch_todo.org).

Thanks anyway.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-23 17:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-02 21:27 Dynamically generating todo entries Daniel Schoepe
2011-11-02 23:11 ` Nick Dokos
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.