Wiskey 5 Alpha <wiskey5al...@gmail.com> writes:

> Hello all.
>
> I am sure this is documented somewhere, but I cant seem to put together
> the correct custom agenda view to support my way of project planning
>
> I have the following todo keywords defined : TODO NEXT DONE WAIT
> I like to list everything as a TODO, even if sub items may be a TODO,
> like this
>
> ** TODO Main Test Project
> *** TODO Main sub project 1
> **** NEXT first task
> *** TODO Main sub project 2 (stuck)
>
> What I would like to see is :
> on my projects list 
> TODO Main sub project 1
>
> The problem is that my project list looks like this
> TODO Main Test Project
> TODO Main sub project 1
>
> I have some projects that are 4 levels deep, so this is quite annoying.
> How do 
> I get just the "deepest" level project to show without it's parents ?

I highly recommend reading this: http://doc.norang.ca/org-mode.html

In particular, if you read this section
http://doc.norang.ca/org-mode.html#Projects you will find functions that
tell you if something is a project (i.e., is a task with a subtask).

I guess one could write something like this:

#+begin_src emacs-lisp
(defun bh/has-subproject-p ()
  "Any task with a todo keyword subtask that is a project"
  (save-restriction
    (widen)
    (let ((has-subproject)
          (subtree-end (save-excursion (org-end-of-subtree t)))
          (is-a-task (member (nth 2 (org-heading-components)) 
org-todo-keywords-1)))
      (save-excursion
        (forward-line 1)
        (while (and (not has-subproject)
                    (< (point) subtree-end)
                    (re-search-forward "^\*+ " subtree-end t))
          (when (bh/is-project-p)
            (setq has-subproject t))))
      (and is-a-task has-subtask))))
#end_src

then combine "is-project-p" and "has-subproject-p" to decide whether to
include something.

Alan

Reply via email to