From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: Agenda: Display projects and 3 todo subtasks Date: Thu, 08 Aug 2019 10:48:01 -0500 Message-ID: <87blwz7j66.fsf@alphapapa.net> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42123) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvkeE-0004nE-2f for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 11:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvkeD-0004BE-7p for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 11:48:14 -0400 Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:57152 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvkeD-0004Aa-1X for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 11:48:13 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hvkeB-0013NQ-3N for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 17:48:11 +0200 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 Nathan, Well, this is an unorthodox solution using org-ql, but it seems to work. So, for what it's worth: #+BEGIN_SRC elisp (let* ((sub-query (lambda () (save-excursion (save-restriction (cons (org-ql--add-markers (org-element-headline-parser (line-end-position))) (-take 3 (progn (org-narrow-to-subtree) (org-ql-select nil '(todo) :narrow t :action 'element-with-markers)))))))) (entries (-flatten-n 1 (org-ql-select buffer '(and (tags "PROJECT") (not (todo))) :action sub-query)))) (org-ql-agenda--agenda nil nil :entries entries)) #+END_SRC This produces an agenda-like view showing (I changed "todo" to "TODO" in the test file): Project 1 :PROJECT: TODO task 1.1 :PROJECT: TODO task 1.2 :PROJECT: TODO task 1.3 :PROJECT: Project 2 :PROJECT: TODO task 2.1 :PROJECT: TODO task 2.2 :PROJECT: TODO task 2.3 :PROJECT: This is a bit awkward, but it's given me an idea about running nested queries, so I'll see if I can make that easier.