From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Porter Subject: Re: Help with "macro" Date: Sat, 12 Oct 2019 15:16:14 -0500 Message-ID: <87k199n2i9.fsf@alphapapa.net> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:54986) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJNoR-00086t-AI for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 16:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJNoP-0004z2-2X for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 16:16:26 -0400 Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:37976 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iJNoO-0004vY-Rq for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 16:16:25 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1iJNoL-0004fJ-Qh for emacs-orgmode@gnu.org; Sat, 12 Oct 2019 22:16:21 +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 Nathan Neff writes: > I'm trying to implement a function to display the TODO items of the > currently highlighted item in the agenda and have a few questions: > > Goal: > > 1) From the agenda, place the cursor on a heading. > > 2) Press a key and instantly narrow the agenda to the heading which > the cursor is on. > > 3) Display org-todo-list for the "narrowed" item in a new buffer, with > the name "agenda for " or perhaps "agenda for "PROP" of the narrowed item" > > 4) Keep the existing original agenda view (using sticky or some other > tactic). Agenda restrictions are awkward to work with. I recommend using org-ql for this sort of thing, since it's designed to do things like this. This seems to work: (defun nn/agenda-item-todos () (interactive) (org-with-point-at (org-get-at-bol 'org-marker) (save-restriction (org-narrow-to-subtree) (org-ql-search (current-buffer) '(todo) :narrow t))))