The "stuck projects" view depends on the hypothesis that you can
clearly identify what a "project means". In the default setup,
are assumed to have LEVEL=2 and should not be DONE.
In the hierarchy you are using, it seems that any entry can be
"projects", and that you do have projects within projects. So the
you need to avoid skipping subtrees and limit yourself to skipping
is the right approach.
However, what you are really asking for is to look only at direct
and in this case is is better to write a special skip function:
(defun org-skip-unless-child-todo ()
(let ((subtree-end (save-excursion (org-end-of-subtree t)))
(entry-end (save-excursion (or (outline-next-heading) (point-
(concat "^" (regexp-quote
(make-string (1+ level) ?*))
(mapconcat 'identity org-not-done-keywords "\\|")
;; skip this entry by returning the entry-end position
;; do not skip this entry by returning nil
As you can see, this function first determines the end of the
(for the search) and the end of the entry positions. Then it
a special regular expression that will only match headlines that are
direct children of the current level. During a tags search, the
"level" variable contains the current level (careful, when you are
using org-odd-levels-only, it contains the reduced level...).
So the special regexp contains one star more that the current, and
any TODO keyword.
If there is a TODO child, the function returns the position at the
entry, to continue search from there.
If there is no mach, it returns nil, meaning that this entry should
*not* be skipped.
The agenda custom command would look like this:
(("0" "Special Stuck" tags "LEVEL>0/-DONE-TODO"
So we select entries that are LEVEL>0, i.e. all entries, but we
that these entries are not TODO entries. OK, these are the
projects. And the we skip them when they have a direct TODO child.