From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: Is there a way to get all agenda TODOs programmatically? Date: Wed, 03 Jan 2018 07:15:11 -0600 Message-ID: <87po6rt76o.fsf@alphapapa.net> References: <87376v36up.fsf@mbork.pl> <87a813rqdx.fsf@fastmail.fm> <87r2ue29j8.fsf@mbork.pl> <874lrasxu2.fsf@fastmail.fm> <877et5joln.fsf@mbork.pl> <87shbqv58k.fsf@alphapapa.net> <87vagjffuq.fsf@mbork.pl> <87vagjtgom.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWitL-0000o2-JN for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 08:15:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWitH-0002rE-Ds for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 08:15:35 -0500 Received: from [195.159.176.226] (port=57407 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWitH-0002qS-6p for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 08:15:31 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eWirF-0002LV-ID for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 14:13:25 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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.