generalized project descention function...not tested
This commit is contained in:
parent
1699aec703
commit
e7bbc55478
21
conf.el
21
conf.el
|
@ -495,6 +495,27 @@ function is not meant to be called independently."
|
|||
(org-forward-heading-same-level 1 t)))
|
||||
found-active))
|
||||
|
||||
;; project level testing
|
||||
(defun nd/test-blocked-project ()
|
||||
(let ((found-active)
|
||||
(found-blocked)
|
||||
(found-held)
|
||||
(previous-point))
|
||||
(save-excursion
|
||||
(setq previous-point (point))
|
||||
(outline-next-heading)
|
||||
;; note, only active tasks can break the loop because we don't know if the final
|
||||
;; heading in the project will be active (and could override the project status)
|
||||
(while (and (not found-active)
|
||||
(> (point) previous-point))
|
||||
(when (or (and (nd/is-project-p)
|
||||
(nd/test-blocked-project))
|
||||
(nd/is-active-task-p))
|
||||
(setq found-active t))
|
||||
(setq previous-point (point))
|
||||
(org-forward-heading-same-level 1 t)))
|
||||
found-active))
|
||||
|
||||
(defun nd/is-active-project-p ()
|
||||
"return keyword if project has at least one
|
||||
active task or project"
|
||||
|
|
32
conf.org
32
conf.org
|
@ -666,7 +666,6 @@ some definitions:
|
|||
(equal (nd/is-task-p) "WAITING"))
|
||||
|
||||
;; org-forward-heading-same-level
|
||||
|
||||
;; project level testing
|
||||
(defun nd/test-first-order-project ()
|
||||
"tests the state of a project assuming first order.
|
||||
|
@ -688,6 +687,37 @@ some definitions:
|
|||
(org-forward-heading-same-level 1 t)))
|
||||
found-active))
|
||||
|
||||
;; project level testing
|
||||
(defun nd/descend-into-project ()
|
||||
"returns numeric value according to state of project:
|
||||
0: stuck
|
||||
1: held
|
||||
2: waiting
|
||||
3: active
|
||||
|
||||
Larger values have precedence over smaller (eg a NEXT
|
||||
keyword will override any other WAITING or HELD task present"
|
||||
(let ((project-state 0)
|
||||
(previous-point))
|
||||
(save-excursion
|
||||
(setq previous-point (point))
|
||||
(outline-next-heading)
|
||||
(while (and (< project-state 3)
|
||||
(> (point) previous-point))
|
||||
(let ((keyword (nd/is-todoitem))
|
||||
(if keyword
|
||||
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project))
|
||||
((equal keyword "HOLD") 1)
|
||||
((equal keyword "WAITING") 2)
|
||||
((equal keyword "NEXT") 3)
|
||||
((nd/is-scheduled-heading) 3)
|
||||
(t 0))))
|
||||
(if (> cur-state project-state)
|
||||
(setq project-state cur-state))))
|
||||
(setq previous-point (point))
|
||||
(org-forward-heading-same-level 1 t)))
|
||||
project-state))
|
||||
|
||||
(defun nd/is-active-project-p ()
|
||||
"return keyword if project has at least one
|
||||
active task or project"
|
||||
|
|
Loading…
Reference in New Issue