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

40
conf.el
View File

@ -226,7 +226,7 @@
(load "ess-site") (load "ess-site")
(setq ess-history-file "session.Rhistory") (setq ess-history-file "session.Rhistory")
(setq ess-history-directory (setq ess-history-directory
(substitute-in-file-name "${XDG_CONFIG_HOME}/r/")) (substitute-in-file-name "${XDG_CONFIG_HOME}/r/"))
(setq org-log-done t) (setq org-log-done t)
(setq org-src-window-setup 'current-window) (setq org-src-window-setup 'current-window)
@ -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 ()

View File

@ -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 ()