fixed and tested descend-into-project

This commit is contained in:
petrucci4prez 2018-03-30 20:54:25 -04:00
parent e7bbc55478
commit c619aae18f
2 changed files with 30 additions and 21 deletions

38
conf.el
View File

@ -473,7 +473,6 @@ and retrieve the keyword"
(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.
@ -496,32 +495,41 @@ function is not meant to be called independently."
found-active))
;; project level testing
(defun nd/test-blocked-project ()
(let ((found-active)
(found-blocked)
(found-held)
(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)
;; 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)
(while (and (< project-state 3)
(> (point) previous-point))
(when (or (and (nd/is-project-p)
(nd/test-blocked-project))
(nd/is-active-task-p))
(setq found-active t))
(let ((keyword (nd/is-todoitem-p)))
(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-p) 3)
(t 0))))
(if (> cur-state project-state)
(setq project-state cur-state)))))
(setq previous-point (point))
(org-forward-heading-same-level 1 t)))
found-active))
project-state))
(defun nd/is-active-project-p ()
"return keyword if project has at least one
active task or project"
(let ((keyword (nd/is-project-p)))
(if keyword
(nd/test-first-order-project))))
(and keyword (equal 3 (nd/descend-into-project)))))
;; task skip functions
(defun nd/skip-non-atomic-tasks ()

View File

@ -704,16 +704,17 @@ some definitions:
(outline-next-heading)
(while (and (< project-state 3)
(> (point) previous-point))
(let ((keyword (nd/is-todoitem))
(let ((keyword (nd/is-todoitem-p)))
(if keyword
;; TODO: filter out project headings like HOLD and DONE
(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)
((nd/is-scheduled-heading-p) 3)
(t 0))))
(if (> cur-state project-state)
(setq project-state cur-state))))
(setq project-state cur-state)))))
(setq previous-point (point))
(org-forward-heading-same-level 1 t)))
project-state))
@ -721,9 +722,9 @@ some definitions:
(defun nd/is-active-project-p ()
"return keyword if project has at least one
active task or project"
;; TODO: skip over projects based on heading alone (eg HOLD and DONE)
(let ((keyword (nd/is-project-p)))
(if keyword
(nd/test-first-order-project))))
(and keyword (equal 3 (nd/descend-into-project)))))
;; task skip functions
(defun nd/skip-non-atomic-tasks ()