Nathan Neff <[email protected]> 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 <heading name>" or perhaps "agenda for <property
> "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))))