Let's say I have a custom TODO tag called 'NEXT' and a file gtd.org which contains the following:

* Some category
** TODO Big project in category
*** NEXT Big step to completing project
**** NEXT Small step to completing big step

In my custom agenda view, I have a block listing everything with a NEXT tag. The problem is that this block lists the big step and the small step, whereas I only want to see the small step. That is, I'm looking for one of the following solutions, from most desirable to least desirable:

  • Do not show a 'NEXT' headline if it has a child with 'NEXT' (probably resource heavy)
  • Sort the agenda block so that greater headline depth is on top
  • Have different blocks for different headline depths

I know that org can detect headline depth, because when setting org-agenda-prefix-format its possible to add a number of spaces spaces to the prefix equaling the headline depth (using %l).

Any ideas?

1 Answer 1


Having studied org-mode for a few weeks, I believe I can answer my own question.

  • To hide headlines with children in TODO states, first put this in your init.el or equivalent:

    (setq org-enforce-todo-dependencies t)

    The above will prevent a headline from entering a DONE state while a child is in a TODO state. TODO headlines with at least one child in a TODO state have the property BLOCKED. To prevent BLOCKED headlines from showing in agenda views, use

    (setq org-agenda-dim-blocked-tasks 'invisible)
  • Sorting the agenda block by headline depth is possible by creating a custom sorting strategy. The depth of a headline is given by the property LEVEL. As an example where LEVEL is used, org defaults to determining stuck projects by first tag searching for "+LEVEL=2/-DONE". For more information, look up the syntax of tag searching.

  • Distinct blocks for distinct headline depths can be achieved by using the LEVEL property, as described above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.