fixed and tested descend-into-project
This commit is contained in:
parent
e7bbc55478
commit
c619aae18f
38
conf.el
38
conf.el
|
@ -473,7 +473,6 @@ and retrieve the keyword"
|
||||||
(equal (nd/is-task-p) "WAITING"))
|
(equal (nd/is-task-p) "WAITING"))
|
||||||
|
|
||||||
;; org-forward-heading-same-level
|
;; org-forward-heading-same-level
|
||||||
|
|
||||||
;; project level testing
|
;; project level testing
|
||||||
(defun nd/test-first-order-project ()
|
(defun nd/test-first-order-project ()
|
||||||
"tests the state of a project assuming first order.
|
"tests the state of a project assuming first order.
|
||||||
|
@ -496,32 +495,41 @@ function is not meant to be called independently."
|
||||||
found-active))
|
found-active))
|
||||||
|
|
||||||
;; project level testing
|
;; project level testing
|
||||||
(defun nd/test-blocked-project ()
|
(defun nd/descend-into-project ()
|
||||||
(let ((found-active)
|
"returns numeric value according to state of project:
|
||||||
(found-blocked)
|
0: stuck
|
||||||
(found-held)
|
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))
|
(previous-point))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(setq previous-point (point))
|
(setq previous-point (point))
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
;; note, only active tasks can break the loop because we don't know if the final
|
(while (and (< project-state 3)
|
||||||
;; heading in the project will be active (and could override the project status)
|
|
||||||
(while (and (not found-active)
|
|
||||||
(> (point) previous-point))
|
(> (point) previous-point))
|
||||||
(when (or (and (nd/is-project-p)
|
(let ((keyword (nd/is-todoitem-p)))
|
||||||
(nd/test-blocked-project))
|
(if keyword
|
||||||
(nd/is-active-task-p))
|
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project))
|
||||||
(setq found-active t))
|
((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))
|
(setq previous-point (point))
|
||||||
(org-forward-heading-same-level 1 t)))
|
(org-forward-heading-same-level 1 t)))
|
||||||
found-active))
|
project-state))
|
||||||
|
|
||||||
(defun nd/is-active-project-p ()
|
(defun nd/is-active-project-p ()
|
||||||
"return keyword if project has at least one
|
"return keyword if project has at least one
|
||||||
active task or project"
|
active task or project"
|
||||||
(let ((keyword (nd/is-project-p)))
|
(let ((keyword (nd/is-project-p)))
|
||||||
(if keyword
|
(and keyword (equal 3 (nd/descend-into-project)))))
|
||||||
(nd/test-first-order-project))))
|
|
||||||
|
|
||||||
;; task skip functions
|
;; task skip functions
|
||||||
(defun nd/skip-non-atomic-tasks ()
|
(defun nd/skip-non-atomic-tasks ()
|
||||||
|
|
11
conf.org
11
conf.org
|
@ -704,16 +704,17 @@ some definitions:
|
||||||
(outline-next-heading)
|
(outline-next-heading)
|
||||||
(while (and (< project-state 3)
|
(while (and (< project-state 3)
|
||||||
(> (point) previous-point))
|
(> (point) previous-point))
|
||||||
(let ((keyword (nd/is-todoitem))
|
(let ((keyword (nd/is-todoitem-p)))
|
||||||
(if keyword
|
(if keyword
|
||||||
|
;; TODO: filter out project headings like HOLD and DONE
|
||||||
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project))
|
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project))
|
||||||
((equal keyword "HOLD") 1)
|
((equal keyword "HOLD") 1)
|
||||||
((equal keyword "WAITING") 2)
|
((equal keyword "WAITING") 2)
|
||||||
((equal keyword "NEXT") 3)
|
((equal keyword "NEXT") 3)
|
||||||
((nd/is-scheduled-heading) 3)
|
((nd/is-scheduled-heading-p) 3)
|
||||||
(t 0))))
|
(t 0))))
|
||||||
(if (> cur-state project-state)
|
(if (> cur-state project-state)
|
||||||
(setq project-state cur-state))))
|
(setq project-state cur-state)))))
|
||||||
(setq previous-point (point))
|
(setq previous-point (point))
|
||||||
(org-forward-heading-same-level 1 t)))
|
(org-forward-heading-same-level 1 t)))
|
||||||
project-state))
|
project-state))
|
||||||
|
@ -721,9 +722,9 @@ some definitions:
|
||||||
(defun nd/is-active-project-p ()
|
(defun nd/is-active-project-p ()
|
||||||
"return keyword if project has at least one
|
"return keyword if project has at least one
|
||||||
active task or project"
|
active task or project"
|
||||||
|
;; TODO: skip over projects based on heading alone (eg HOLD and DONE)
|
||||||
(let ((keyword (nd/is-project-p)))
|
(let ((keyword (nd/is-project-p)))
|
||||||
(if keyword
|
(and keyword (equal 3 (nd/descend-into-project)))))
|
||||||
(nd/test-first-order-project))))
|
|
||||||
|
|
||||||
;; task skip functions
|
;; task skip functions
|
||||||
(defun nd/skip-non-atomic-tasks ()
|
(defun nd/skip-non-atomic-tasks ()
|
||||||
|
|
Loading…
Reference in New Issue