During my daily work I want to prevent parent tasks to be visible in my daily agenda views. This is very practical during daily work, since a parent task cannot be "done", only be a placeholder for its sibling tasks. However, during my GTD weekly review of my tasks I would like to have a separate agende view showing all parent tasks, to be able to get an overview of their sibling tasks and their status.

I use the following code to make task dependencies possible and to prevent showing parent tasks.

(setq org-enforce-todo-dependencies t)
(setq org-agenda-dim-blocked-tasks 'invisible)

If I use the code above, how can I make an agenda view that show only my parent tasks? What is lacking in the agenda view code below?

(setq org-agenda-custom-commands '(
        ("p" "parent tasks" tags < ...missing code... > (
        (org-agenda-overriding-header "Parent tasks")

Or what changes do I have to make in my code to be able to BOTH not showing parent tasks in some views, AND to show them in other views?

I do not want to manually tag the parent views with "PROJECT", since this is extra work that can easily be forgotten, and thereby clutter my daily and weekly agenda views.

Thanks in advance for any help !

1 Answer 1


If parent tasks are exactly those that are blocked, then you can define a org-agenda-skip-function to omit anything that isn't blocked. You can use the options block to temporarily change variables related to blocking (for example org-enforce-todo-checkbox-dependencies) to things aren't block spuriously.

Skip functions will be called with the point at each heading the agenda checks and are expected to return either nil (when the entry should not be skipped) or the location of the next heading the agenda should check (often the next entry, but you could skip entire subtrees here).

Here's a function that just checks each entry for blocking with org-entry-blocked-p:

(defun org-agenda-skip-if-not-blocked ()
  (let ((next-headline (save-excursion
                         (or (outline-next-heading) (point-max)))))
    (if (not (org-entry-blocked-p)) next-headline)))

(add-to-list 'org-agenda-custom-commands
             '("B" "Blocked entries" alltodo ""
               ((org-agenda-skip-function '(org-agenda-skip-if-not-blocked))
                (org-enforce-todo-checkbox-dependencies nil))

If there is some more complex rule for identifying parent tasks, then take a look at org-stuck-projects.

  • Hi erikstokes, and thansk for your ansver. I am afraid the parent tasks are NOT the only ones to be blocked, because I am using the following two lines: (setq org-enforce-todo-checkbox-dependencies t) (setq org-track-ordered-property-with-tag t) If I have understood this right, the first code line is blocking a task from being switched to "DONE" if not all its checkboxes are crossed. The second code line blocs a subtask to be switched to "DONE" mode if not all its fellow subtask above it are in "DONE" modus. Hence, some of the sibling tasks under a parent task might also be blocked.
    – myotis
    Aug 13, 2015 at 21:41
  • You could temporarily set them to nil in this template so a task is only blocked if it has undone children.
    – erikstokes
    Aug 13, 2015 at 22:33
  • How could I temporarily set them to nil inside your code?
    – myotis
    Aug 14, 2015 at 8:48
  • You can set any variables by adding (variable value) to the options list at the end of the template. See the help for org-agenda-custom-functions. Only org-enforce-checkbox-depencies is relevant here. org-track-ordered-property-with-tag doesn't change the blocking behaviour.
    – erikstokes
    Aug 15, 2015 at 16:16
  • Erikstokes: Sorry for my delayed response, but for some reason the code does not sort out any blocked tasks (partent -tasks). I am testing to see if I have done some thing obviously wrong..
    – myotis
    Aug 16, 2015 at 20:23

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.