emacs-orgmode@gnu.org archives
 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: Wed, 03 Jan 2018 07:15:11 -0600	[thread overview]
Message-ID: <87po6rt76o.fsf@alphapapa.net> (raw)
In-Reply-To: 87vagjtgom.fsf@alphapapa.net

Hi Marcin (and all),

I have some more code you might find useful.  I had an idea to take a
different approach with my org-agenda-ng code (not using org-element to
parse the whole buffer first), and it seems to be working well so far.
The code is here:

https://github.com/alphapapa/org-agenda-ng/tree/non-element-parsing

The code doesn't generate an identical result to the org-agenda code
(not yet, anyway), but it's very similar.  It lacks the agenda prefix
feature and full application of agenda faces (it does do a few faces
already).  Most, if not all, text properties are applied.  And of
course, more work could be done to make it look more like an official
agenda buffer.

So, for an example, you can run code like this to simulate a primitive
agenda buffer:

(org-agenda-ng--agenda
 :files org-agenda-files
 :any `((org-agenda-ng--date-p :date <= ,(org-today))
        (org-agenda-ng--date-p :deadline <= ,(+ org-deadline-warning-days (org-today)))
        (org-agenda-ng--date-p :scheduled <= ,(org-today)))
 :none `((apply org-agenda-ng--todo-p ,org-done-keywords)))

Or you could search for certain types of to-do items with a deadline
before a certain date like:

(org-agenda-ng--agenda
 :files "~/org/main.org"
 :all '((org-agenda-ng--todo-p "TODO" "WAITING")
        (org-agenda-ng--date-p :deadline < "2018-01-03")))

As you can see, the :all, :any, and :none arguments are a list of quoted
lisp forms.  You can also give your own lambda, like:

(org-agenda-ng--agenda
 :files org-agenda-files
 :pred (lambda ()
         (and (org-agenda-ng--todo-p)
              (or (org-agenda-ng--date-p :deadline '<= (org-today))
                  (org-agenda-ng--date-p :scheduled '<= (org-today)))
              (not (apply #'org-agenda-ng--todo-p org-done-keywords-for-agenda)))))

If you also give :all, :any, or :none, they are AND-ed with the :pred
lambda.

It's all highly experimental and WIP, but feel free to try it out, and
please let me know any feedback you might have.

  reply	other threads:[~2018-01-03 13:15 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
2018-01-03  9:31           ` Marcin Borkowski
2018-01-03  9:50             ` Adam Porter
2018-01-03 13:15               ` Adam Porter [this message]
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

  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=87po6rt76o.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 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).