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 08:19:13 -0600 Message-ID: <87h8s3t47y.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> <87po6rt76o.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWjvw-0005ss-Kq for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 09:22:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWjvr-0006E1-OR for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 09:22:20 -0500 Received: from [195.159.176.226] (port=35752 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWjvr-0006Df-HM for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 09:22:15 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eWjtp-0001l9-07 for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 15:20:09 +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 Forgive the self reply, but I just made a change which makes the code much more pleasant. The matching functions are bound internally during matching, so instead of: (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))))) You can write: (org-agenda-ng--agenda :files org-agenda-files :pred (lambda () (and (todo) (or (date :deadline '<= (org-today)) (date :scheduled '<= (org-today))) (not (apply #'todo org-done-keywords-for-agenda))))) Or: (org-agenda-ng--agenda :files org-agenda-files :any `((date :date <= ,(org-today)) (date :deadline <= ,(+ org-deadline-warning-days (org-today))) (date :scheduled <= ,(org-today))) :none `((apply todo ,org-done-keywords))) This makes the syntax much more pleasant and readable, I think. I also profiled the code, and its performance seems good.