all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-orgmode@gnu.org
Subject: Re: Is there a way to get all agenda TODOs programmatically?
Date: Sun, 31 Dec 2017 17:37:31 -0600	[thread overview]
Message-ID: <87shbqv58k.fsf@alphapapa.net> (raw)
In-Reply-To: 877et5joln.fsf@mbork.pl

Marcin Borkowski <mbork@mbork.pl> writes:

> Thanks again.  I played around with this for some time, but there is one
> problem.  The agenda has a lot of settings, and replicating them with
> org-map-entries turned out to be no fun.
>
> Is there a way to plug into the agenda generating functions somehow to
> get a Lisp list of agenda items?  I'm pretty sure that can be done -
> org-super-agenda does something similar, after all - but I have no idea
> why.  I could delve into agenda source myself, but is is quite hairy, so
> maybe someone knows that already?

Hi Marcin,

As you said, the agenda code is quite hairy--but it does work very well.
My meager attempt to begin reimplementing it in a more functional way
showed very poor performance by comparison; perhaps because I didn't do
it well, but I'm guessing also because of Emacs' function call overhead.
But for your project, perhaps the code would come in useful; feel free
to borrow anything that you like:

https://github.com/alphapapa/org-agenda-ng

As you mentioned, org-super-agenda simply uses the raw output of the
org-agenda commands by reading it from the agenda buffer.  This works
well because each line in the agenda buffer is an item, and the text on
each line has Emacs text-properties that include most of the relevant
metadata (anything else can be retrieved by using a macro to eval code
at the item's marker--see org-super-agenda--when-with-marker-buffer,
which I should probably rename, haha).  So getting a list of agenda
items could be as simple as running this in the agenda buffer:

(split-string (buffer-substring (point-min) (point-max))
              "\n" 'omit-nulls)

org-super-agenda does that by using advice to filter the return of
org-agenda-finalize-entries, which you could also do quite easily.

So while the agenda code is relatively opaque, it's easier to use its
output than you might think.  :) Let me know if I can help.  (I haven't
been monitoring the list lately, so you might email me directly if
necessary.)  Good luck!

  reply	other threads:[~2017-12-31 23:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-07  4:43 Is there a way to get all agenda TODOs programmatically? Marcin Borkowski
2017-10-07 14:20 ` Matt Lundin
2017-10-07 16:43   ` Marcin Borkowski
2017-10-07 16:54     ` Matt Lundin
2017-12-29 19:55       ` Marcin Borkowski
2017-12-31 23:37         ` Adam Porter [this message]
2018-01-03  9:31           ` Marcin Borkowski
2018-01-03  9:50             ` Adam Porter
2018-01-03 13:15               ` Adam Porter
2018-01-03 14:15                 ` Nicolas Goaziou
2018-01-03 15:48                   ` Adam Porter
2018-01-03 14:19                 ` Adam Porter
2018-01-03 13:49               ` Nicolas Goaziou
2018-01-03 14:16                 ` Adam Porter

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

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

  git send-email \
    --in-reply-to=87shbqv58k.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --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 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.