began testing skip functions

This commit is contained in:
petrucci4prez 2018-03-31 01:43:17 -04:00
parent c619aae18f
commit 834e1270ca
2 changed files with 236 additions and 232 deletions

231
conf.el
View File

@ -350,57 +350,54 @@
(tags "REFILE" (tags "REFILE"
((org-agenda-overriding-header "Tasks to Refile") ((org-agenda-overriding-header "Tasks to Refile")
(org-tags-match-list-sublevels nil))) (org-tags-match-list-sublevels nil)))
(tags-todo "-NA-CANCELLED/!NEXT" ;; (tags-todo "-NA-CANCELLED/!NEXT"
((org-agenda-overriding-header (concat "Project Next Tasks" ;; ((org-agenda-overriding-header (concat "Project Next Tasks"
(if nd/hide-scheduled-and-waiting-next-tasks ;; (if nd/hide-scheduled-and-waiting-next-tasks
"" ;; ""
" (including WAITING and SCHEDULED tasks)"))) ;; " (including WAITING and SCHEDULED tasks)")))
(org-agenda-skip-function 'nd/skip-projects-and-habits-and-single-tasks) ;; (org-agenda-skip-function 'nd/skip-projects-and-habits-and-single-tasks)
(org-tags-match-list-sublevels t) ;; (org-tags-match-list-sublevels t)
(org-agenda-todo-ignore-with-date 'all) ;; (org-agenda-todo-ignore-with-date 'all)
(org-agenda-sorting-strategy ;; (org-agenda-sorting-strategy
'(todo-state-down effort-up category-keep)))) ;; '(todo-state-down effort-up category-keep))))
(tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!" ;; (tags-todo "-NA-REFILE/!"
((org-agenda-overriding-header (concat "Atomic Tasks" ;; ((org-agenda-overriding-header (concat "Atomic Tasks"))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-atomic-tasks)
"" ;; ;;(org-agenda-todo-ignore-with-date 'all)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-sorting-strategy
(org-agenda-skip-function 'nd/skip-non-atomic-tasks) ;; '(category-keep))))
(org-agenda-todo-ignore-with-date 'all) ;; (tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!"
(org-agenda-sorting-strategy ;; ((org-agenda-overriding-header (concat "Project Subtasks"
'(category-keep)))) ;; (if nd/hide-scheduled-and-waiting-next-tasks
(tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!" ;; ""
((org-agenda-overriding-header (concat "Project Subtasks" ;; " (including WAITING and SCHEDULED tasks)")))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-project-tasks)
"" ;; (org-agenda-todo-ignore-with-date 'all)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-sorting-strategy
(org-agenda-skip-function 'nd/skip-non-project-tasks) ;; '(category-keep))))
(org-agenda-todo-ignore-with-date 'all) ;; (tags-todo "-NA-CANCELLED+WAITING|HOLD/!"
(org-agenda-sorting-strategy ;; ((org-agenda-overriding-header (concat "Waiting and Postponed Tasks"
'(category-keep)))) ;; (if nd/hide-scheduled-and-waiting-next-tasks
(tags-todo "-NA-CANCELLED+WAITING|HOLD/!" ;; ""
((org-agenda-overriding-header (concat "Waiting and Postponed Tasks" ;; " (including WAITING and SCHEDULED tasks)")))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-tasks)
"" ;; (org-tags-match-list-sublevels nil)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-todo-ignore-with-date 'all)))
(org-agenda-skip-function 'nd/skip-non-tasks) (tags-todo "-NA-REFILE/!"
(org-tags-match-list-sublevels nil)
(org-agenda-todo-ignore-with-date 'all)))
(tags-todo "-NA-CANCELLED/!"
((org-agenda-overriding-header "Stuck Projects") ((org-agenda-overriding-header "Stuck Projects")
(org-agenda-skip-function 'nd/skip-non-stuck-projects) (org-agenda-skip-function 'nd/skip-non-stuck-projects)
(org-agenda-sorting-strategy (org-agenda-sorting-strategy
'(category-keep)))) '(category-keep)))))
(tags-todo "-NA-HOLD-CANCELLED/!" ;; (tags-todo "-NA-REFILE/!"
((org-agenda-overriding-header "Projects") ;; ((org-agenda-overriding-header "Projects")
(org-agenda-skip-function 'nd/skip-non-projects) ;; (org-agenda-skip-function 'nd/skip-non-projects)
(org-tags-match-list-sublevels 'indented) ;; (org-tags-match-list-sublevels 'indented)
(org-agenda-sorting-strategy ;; (org-agenda-sorting-strategy
'(category-keep)))) ;; '(category-keep))))
(tags "-NA-REFILE/" ;; (tags "-NA-REFILE/"
((org-agenda-overriding-header "Tasks to Archive") ;; ((org-agenda-overriding-header "Tasks to Archive")
(org-agenda-skip-function 'nd/skip-non-archivable-tasks) ;; (org-agenda-skip-function 'nd/skip-non-archivable-tasks)
(org-tags-match-list-sublevels nil)))) ;; (org-tags-match-list-sublevels nil))))
nil)))) nil))))
(defun nd/org-auto-exclude-function (tag) (defun nd/org-auto-exclude-function (tag)
@ -422,7 +419,7 @@ and retrieve the keyword"
keyword))) keyword)))
(defun nd/heading-has-children () (defun nd/heading-has-children ()
"returns t if heading has todoitems in its subtree" "returns t if heading has todoitems in its immediate subtree"
(let ((has-children) (let ((has-children)
(subtree-end (save-excursion (org-end-of-subtree t)))) (subtree-end (save-excursion (org-end-of-subtree t))))
(save-excursion (save-excursion
@ -430,33 +427,26 @@ and retrieve the keyword"
(while (and (not has-children) (while (and (not has-children)
(< (point) subtree-end)) (< (point) subtree-end))
(when (nd/is-todoitem-p) (when (nd/is-todoitem-p)
(setq has-children t) (setq has-children t))
(outline-next-heading)))) ;; (org-forward-heading-same-level 1 t)))
(outline-next-heading)))
has-children)) has-children))
(defun nd/heading-has-parent () (defun nd/heading-has-parent ()
"returns t if heading is in the subtree of a todoitem" "returns parent keyword if heading is in the immediate subtree of a todoitem"
(let ((has-parent)) (save-excursion (and (org-up-heading-safe) (nd/is-todoitem-p))))
(save-excursion
(while (and (not has-parent) (org-up-heading-safe))
(when (nd/is-todoitem-p)
(setq has-parent t))))
has-parent))
(defun nd/is-project-p () (defun nd/is-project-p ()
"return todo keyword if heading is todoitem and has children" "return todo keyword if heading is todoitem and has children"
(and (nd/heading-has-children) (and (nd/heading-has-children) (nd/is-todoitem-p)))
(nd/is-todoitem-p)))
(defun nd/is-task-p () (defun nd/is-task-p ()
"return todo keyword if heading is todoitem with no children" "return todo keyword if heading is todoitem with no children"
(and (not (nd/heading-has-children)) (and (not (nd/heading-has-children)) (nd/is-todoitem-p)))
(nd/is-todoitem-p)))
(defun nd/is-atomic-task-p () (defun nd/is-atomic-task-p ()
"return todo keyword if heading is task with no parents" "return todo keyword if heading is task with no parents"
(and (not (nd/heading-has-parent)) (and (not (nd/heading-has-parent)) (nd/is-task-p)))
(nd/is-task-p)))
(defun nd/is-scheduled-heading-p () (defun nd/is-scheduled-heading-p ()
"return timestamp if headline is scheduled" "return timestamp if headline is scheduled"
@ -494,6 +484,9 @@ function is not meant to be called independently."
(org-forward-heading-same-level 1 t))) (org-forward-heading-same-level 1 t)))
found-active)) found-active))
;; projects that have these keywords are not considered in determining status
(defvar nd/project-skip-keywords '("HOLD" "DONE" "CANCELLED"))
;; project level testing ;; project level testing
(defun nd/descend-into-project () (defun nd/descend-into-project ()
"returns numeric value according to state of project: "returns numeric value according to state of project:
@ -513,7 +506,9 @@ keyword will override any other WAITING or HELD task present"
(> (point) previous-point)) (> (point) previous-point))
(let ((keyword (nd/is-todoitem-p))) (let ((keyword (nd/is-todoitem-p)))
(if keyword (if keyword
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project)) (let ((cur-state (cond ((and (not (member keyword nd/project-skip-keywords))
(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)
@ -525,47 +520,55 @@ keyword will override any other WAITING or HELD task present"
(org-forward-heading-same-level 1 t))) (org-forward-heading-same-level 1 t)))
project-state)) project-state))
(defun nd/is-active-project-p () (defun nd/is-project-status-p (statuscode)
"return keyword if project has at least one ;;TODO maybe return keyword here to consistant?
active task or project"
(let ((keyword (nd/is-project-p))) (let ((keyword (nd/is-project-p)))
(and keyword (equal 3 (nd/descend-into-project))))) (and keyword
(not (member keyword nd/project-skip-keywords))
(equal statuscode (nd/descend-into-project)))))
;; task skip functions ;; task skip functions
;; NOTE: use save-restriction and widen if we ever actually use narrowing
(defun nd/skip-non-atomic-tasks () (defun nd/skip-non-atomic-tasks ()
(save-restriction (if (not (nd/is-atomic-task-p))
(widen) (save-excursion (or (outline-next-heading) (point-max)))))
(if (not (and ((nd/is-atomic-p) (not (nd/is-subtask-p)))))
(save-excursion (or (outline-next-heading) (point-max))))))
(defvar nd/hide-scheduled-and-waiting-next-tasks t) (defun nd/skip-non-projects ()
(if (not (nd/is-project-p))
(defun nd/toggle-next-task-display () (save-excursion (or (outline-next-heading) (point-max)))))
(interactive)
(setq nd/hide-scheduled-and-waiting-next-tasks (not nd/hide-scheduled-and-waiting-next-tasks))
(when (equal major-mode 'org-agenda-mode)
(org-agenda-redo))
(message "%s WAITING and SCHEDULED NEXT Tasks" (if nd/hide-scheduled-and-waiting-next-tasks "Hide" "Show")))
(defun nd/skip-non-stuck-projects () (defun nd/skip-non-stuck-projects ()
"Skip trees that are not stuck projects" (if (not (nd/is-project-status-p 0))
(save-restriction (save-excursion (or (outline-next-heading) (point-max)))))
(widen)
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max))))) ;; (defvar nd/hide-scheduled-and-waiting-next-tasks t)
(if (nd/is-project-p)
(let* ((subtree-end (save-excursion (org-end-of-subtree t))) ;; (defun nd/toggle-next-task-display ()
(has-next )) ;; (interactive)
(save-excursion ;; (setq nd/hide-scheduled-and-waiting-next-tasks (not nd/hide-scheduled-and-waiting-next-tasks))
(forward-line 1) ;; (when (equal major-mode 'org-agenda-mode)
(while (and (not has-next) ;; (org-agenda-redo))
(< (point) subtree-end) ;; (message "%s WAITING and SCHEDULED NEXT Tasks" (if nd/hide-scheduled-and-waiting-next-tasks "Hide" "Show")))
(re-search-forward "^\\*+ NEXT " subtree-end t))
(unless (member "WAITING" (org-get-tags-at)) ;; (defun nd/skip-non-stuck-projects ()
(setq has-next t)))) ;; "Skip trees that are not stuck projects"
(if has-next ;; (save-restriction
next-headline ;; (widen)
nil)) ; a stuck project, has subtasks but no next task ;; (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
next-headline)))) ;; (if (nd/is-project-p)
;; (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
;; (has-next ))
;; (save-excursion
;; (forward-line 1)
;; (while (and (not has-next)
;; (< (point) subtree-end)
;; (re-search-forward "^\\*+ NEXT " subtree-end t))
;; (unless (member "WAITING" (org-get-tags-at))
;; (setq has-next t))))
;; (if has-next
;; next-headline
;; nil)) ; a stuck project, has subtasks but no next task
;; next-headline))))
;; project test functions ;; project test functions
;; is state ;; is state
@ -603,21 +606,21 @@ active task or project"
;; skip (either an atomic task or non-todo, return next heading) ;; skip (either an atomic task or non-todo, return next heading)
;; ) ;; )
(defun nd/skip-non-projects () ;; (defun nd/skip-non-projects ()
"Skip trees that are not projects" ;; "Skip trees that are not projects"
;; (nd/list-sublevels-for-projects-indented) ;; ;; (nd/list-sublevels-for-projects-indented)
(if (save-excursion (nd/skip-non-stuck-projects)) ;; (if (save-excursion (nd/skip-non-stuck-projects))
(save-restriction ;; (save-restriction
(widen) ;; (widen)
(let ((subtree-end (save-excursion (org-end-of-subtree t)))) ;; (let ((subtree-end (save-excursion (org-end-of-subtree t))))
(cond ;; (cond
((nd/is-project-p) ;; ((nd/is-project-p)
nil) ;; nil)
((and (nd/is-subtask-p) (not (nd/is-atomic-p))) ;; ((and (nd/is-subtask-p) (not (nd/is-atomic-p)))
nil) ;; nil)
(t ;; (t
subtree-end)))) ;; subtree-end))))
(save-excursion (org-end-of-subtree t)))) ;; (save-excursion (org-end-of-subtree t))))
(defun nd/skip-non-tasks () (defun nd/skip-non-tasks ()
"Show non-project tasks. "Show non-project tasks.

233
conf.org
View File

@ -527,57 +527,54 @@ TODO: add meeting template as scheduled+action item thing
(tags "REFILE" (tags "REFILE"
((org-agenda-overriding-header "Tasks to Refile") ((org-agenda-overriding-header "Tasks to Refile")
(org-tags-match-list-sublevels nil))) (org-tags-match-list-sublevels nil)))
(tags-todo "-NA-CANCELLED/!NEXT" ;; (tags-todo "-NA-CANCELLED/!NEXT"
((org-agenda-overriding-header (concat "Project Next Tasks" ;; ((org-agenda-overriding-header (concat "Project Next Tasks"
(if nd/hide-scheduled-and-waiting-next-tasks ;; (if nd/hide-scheduled-and-waiting-next-tasks
"" ;; ""
" (including WAITING and SCHEDULED tasks)"))) ;; " (including WAITING and SCHEDULED tasks)")))
(org-agenda-skip-function 'nd/skip-projects-and-habits-and-single-tasks) ;; (org-agenda-skip-function 'nd/skip-projects-and-habits-and-single-tasks)
(org-tags-match-list-sublevels t) ;; (org-tags-match-list-sublevels t)
(org-agenda-todo-ignore-with-date 'all) ;; (org-agenda-todo-ignore-with-date 'all)
(org-agenda-sorting-strategy ;; (org-agenda-sorting-strategy
'(todo-state-down effort-up category-keep)))) ;; '(todo-state-down effort-up category-keep))))
(tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!" ;; (tags-todo "-NA-REFILE/!"
((org-agenda-overriding-header (concat "Atomic Tasks" ;; ((org-agenda-overriding-header (concat "Atomic Tasks"))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-atomic-tasks)
"" ;; ;;(org-agenda-todo-ignore-with-date 'all)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-sorting-strategy
(org-agenda-skip-function 'nd/skip-non-atomic-tasks) ;; '(category-keep))))
(org-agenda-todo-ignore-with-date 'all) ;; (tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!"
(org-agenda-sorting-strategy ;; ((org-agenda-overriding-header (concat "Project Subtasks"
'(category-keep)))) ;; (if nd/hide-scheduled-and-waiting-next-tasks
(tags-todo "-NA-REFILE-CANCELLED-WAITING-HOLD/!" ;; ""
((org-agenda-overriding-header (concat "Project Subtasks" ;; " (including WAITING and SCHEDULED tasks)")))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-project-tasks)
"" ;; (org-agenda-todo-ignore-with-date 'all)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-sorting-strategy
(org-agenda-skip-function 'nd/skip-non-project-tasks) ;; '(category-keep))))
(org-agenda-todo-ignore-with-date 'all) ;; (tags-todo "-NA-CANCELLED+WAITING|HOLD/!"
(org-agenda-sorting-strategy ;; ((org-agenda-overriding-header (concat "Waiting and Postponed Tasks"
'(category-keep)))) ;; (if nd/hide-scheduled-and-waiting-next-tasks
(tags-todo "-NA-CANCELLED+WAITING|HOLD/!" ;; ""
((org-agenda-overriding-header (concat "Waiting and Postponed Tasks" ;; " (including WAITING and SCHEDULED tasks)")))
(if nd/hide-scheduled-and-waiting-next-tasks ;; (org-agenda-skip-function 'nd/skip-non-tasks)
"" ;; (org-tags-match-list-sublevels nil)
" (including WAITING and SCHEDULED tasks)"))) ;; (org-agenda-todo-ignore-with-date 'all)))
(org-agenda-skip-function 'nd/skip-non-tasks) (tags-todo "-NA-REFILE/!"
(org-tags-match-list-sublevels nil)
(org-agenda-todo-ignore-with-date 'all)))
(tags-todo "-NA-CANCELLED/!"
((org-agenda-overriding-header "Stuck Projects") ((org-agenda-overriding-header "Stuck Projects")
(org-agenda-skip-function 'nd/skip-non-stuck-projects) (org-agenda-skip-function 'nd/skip-non-stuck-projects)
(org-agenda-sorting-strategy (org-agenda-sorting-strategy
'(category-keep)))) '(category-keep)))))
(tags-todo "-NA-HOLD-CANCELLED/!" ;; (tags-todo "-NA-REFILE/!"
((org-agenda-overriding-header "Projects") ;; ((org-agenda-overriding-header "Projects")
(org-agenda-skip-function 'nd/skip-non-projects) ;; (org-agenda-skip-function 'nd/skip-non-projects)
(org-tags-match-list-sublevels 'indented) ;; (org-tags-match-list-sublevels 'indented)
(org-agenda-sorting-strategy ;; (org-agenda-sorting-strategy
'(category-keep)))) ;; '(category-keep))))
(tags "-NA-REFILE/" ;; (tags "-NA-REFILE/"
((org-agenda-overriding-header "Tasks to Archive") ;; ((org-agenda-overriding-header "Tasks to Archive")
(org-agenda-skip-function 'nd/skip-non-archivable-tasks) ;; (org-agenda-skip-function 'nd/skip-non-archivable-tasks)
(org-tags-match-list-sublevels nil)))) ;; (org-tags-match-list-sublevels nil))))
nil)))) nil))))
#+END_SRC #+END_SRC
@ -615,7 +612,7 @@ some definitions:
keyword))) keyword)))
(defun nd/heading-has-children () (defun nd/heading-has-children ()
"returns t if heading has todoitems in its subtree" "returns t if heading has todoitems in its immediate subtree"
(let ((has-children) (let ((has-children)
(subtree-end (save-excursion (org-end-of-subtree t)))) (subtree-end (save-excursion (org-end-of-subtree t))))
(save-excursion (save-excursion
@ -623,33 +620,26 @@ some definitions:
(while (and (not has-children) (while (and (not has-children)
(< (point) subtree-end)) (< (point) subtree-end))
(when (nd/is-todoitem-p) (when (nd/is-todoitem-p)
(setq has-children t) (setq has-children t))
(outline-next-heading)))) ;; (org-forward-heading-same-level 1 t)))
(outline-next-heading)))
has-children)) has-children))
(defun nd/heading-has-parent () (defun nd/heading-has-parent ()
"returns t if heading is in the subtree of a todoitem" "returns parent keyword if heading is in the immediate subtree of a todoitem"
(let ((has-parent)) (save-excursion (and (org-up-heading-safe) (nd/is-todoitem-p))))
(save-excursion
(while (and (not has-parent) (org-up-heading-safe))
(when (nd/is-todoitem-p)
(setq has-parent t))))
has-parent))
(defun nd/is-project-p () (defun nd/is-project-p ()
"return todo keyword if heading is todoitem and has children" "return todo keyword if heading is todoitem and has children"
(and (nd/heading-has-children) (and (nd/heading-has-children) (nd/is-todoitem-p)))
(nd/is-todoitem-p)))
(defun nd/is-task-p () (defun nd/is-task-p ()
"return todo keyword if heading is todoitem with no children" "return todo keyword if heading is todoitem with no children"
(and (not (nd/heading-has-children)) (and (not (nd/heading-has-children)) (nd/is-todoitem-p)))
(nd/is-todoitem-p)))
(defun nd/is-atomic-task-p () (defun nd/is-atomic-task-p ()
"return todo keyword if heading is task with no parents" "return todo keyword if heading is task with no parents"
(and (not (nd/heading-has-parent)) (and (not (nd/heading-has-parent)) (nd/is-task-p)))
(nd/is-task-p)))
(defun nd/is-scheduled-heading-p () (defun nd/is-scheduled-heading-p ()
"return timestamp if headline is scheduled" "return timestamp if headline is scheduled"
@ -687,6 +677,9 @@ some definitions:
(org-forward-heading-same-level 1 t))) (org-forward-heading-same-level 1 t)))
found-active)) found-active))
;; projects that have these keywords are not considered in determining status
(defvar nd/project-skip-keywords '("HOLD" "DONE" "CANCELLED"))
;; project level testing ;; project level testing
(defun nd/descend-into-project () (defun nd/descend-into-project ()
"returns numeric value according to state of project: "returns numeric value according to state of project:
@ -706,8 +699,9 @@ some definitions:
(> (point) previous-point)) (> (point) previous-point))
(let ((keyword (nd/is-todoitem-p))) (let ((keyword (nd/is-todoitem-p)))
(if keyword (if keyword
;; TODO: filter out project headings like HOLD and DONE (let ((cur-state (cond ((and (not (member keyword nd/project-skip-keywords))
(let ((cur-state (cond ((nd/heading-has-children) (nd/descend-into-project)) (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)
@ -719,48 +713,55 @@ some definitions:
(org-forward-heading-same-level 1 t))) (org-forward-heading-same-level 1 t)))
project-state)) project-state))
(defun nd/is-active-project-p () (defun nd/is-project-status-p (statuscode)
"return keyword if project has at least one ;;TODO maybe return keyword here to consistant?
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)))
(and keyword (equal 3 (nd/descend-into-project))))) (and keyword
(not (member keyword nd/project-skip-keywords))
(equal statuscode (nd/descend-into-project)))))
;; task skip functions ;; task skip functions
;; NOTE: use save-restriction and widen if we ever actually use narrowing
(defun nd/skip-non-atomic-tasks () (defun nd/skip-non-atomic-tasks ()
(save-restriction (if (not (nd/is-atomic-task-p))
(widen) (save-excursion (or (outline-next-heading) (point-max)))))
(if (not (and ((nd/is-atomic-p) (not (nd/is-subtask-p)))))
(save-excursion (or (outline-next-heading) (point-max))))))
(defvar nd/hide-scheduled-and-waiting-next-tasks t) (defun nd/skip-non-projects ()
(if (not (nd/is-project-p))
(defun nd/toggle-next-task-display () (save-excursion (or (outline-next-heading) (point-max)))))
(interactive)
(setq nd/hide-scheduled-and-waiting-next-tasks (not nd/hide-scheduled-and-waiting-next-tasks))
(when (equal major-mode 'org-agenda-mode)
(org-agenda-redo))
(message "%s WAITING and SCHEDULED NEXT Tasks" (if nd/hide-scheduled-and-waiting-next-tasks "Hide" "Show")))
(defun nd/skip-non-stuck-projects () (defun nd/skip-non-stuck-projects ()
"Skip trees that are not stuck projects" (if (not (nd/is-project-status-p 0))
(save-restriction (save-excursion (or (outline-next-heading) (point-max)))))
(widen)
(let ((next-headline (save-excursion (or (outline-next-heading) (point-max))))) ;; (defvar nd/hide-scheduled-and-waiting-next-tasks t)
(if (nd/is-project-p)
(let* ((subtree-end (save-excursion (org-end-of-subtree t))) ;; (defun nd/toggle-next-task-display ()
(has-next )) ;; (interactive)
(save-excursion ;; (setq nd/hide-scheduled-and-waiting-next-tasks (not nd/hide-scheduled-and-waiting-next-tasks))
(forward-line 1) ;; (when (equal major-mode 'org-agenda-mode)
(while (and (not has-next) ;; (org-agenda-redo))
(< (point) subtree-end) ;; (message "%s WAITING and SCHEDULED NEXT Tasks" (if nd/hide-scheduled-and-waiting-next-tasks "Hide" "Show")))
(re-search-forward "^\\*+ NEXT " subtree-end t))
(unless (member "WAITING" (org-get-tags-at)) ;; (defun nd/skip-non-stuck-projects ()
(setq has-next t)))) ;; "Skip trees that are not stuck projects"
(if has-next ;; (save-restriction
next-headline ;; (widen)
nil)) ; a stuck project, has subtasks but no next task ;; (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
next-headline)))) ;; (if (nd/is-project-p)
;; (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
;; (has-next ))
;; (save-excursion
;; (forward-line 1)
;; (while (and (not has-next)
;; (< (point) subtree-end)
;; (re-search-forward "^\\*+ NEXT " subtree-end t))
;; (unless (member "WAITING" (org-get-tags-at))
;; (setq has-next t))))
;; (if has-next
;; next-headline
;; nil)) ; a stuck project, has subtasks but no next task
;; next-headline))))
;; project test functions ;; project test functions
;; is state ;; is state
@ -798,21 +799,21 @@ some definitions:
;; skip (either an atomic task or non-todo, return next heading) ;; skip (either an atomic task or non-todo, return next heading)
;; ) ;; )
(defun nd/skip-non-projects () ;; (defun nd/skip-non-projects ()
"Skip trees that are not projects" ;; "Skip trees that are not projects"
;; (nd/list-sublevels-for-projects-indented) ;; ;; (nd/list-sublevels-for-projects-indented)
(if (save-excursion (nd/skip-non-stuck-projects)) ;; (if (save-excursion (nd/skip-non-stuck-projects))
(save-restriction ;; (save-restriction
(widen) ;; (widen)
(let ((subtree-end (save-excursion (org-end-of-subtree t)))) ;; (let ((subtree-end (save-excursion (org-end-of-subtree t))))
(cond ;; (cond
((nd/is-project-p) ;; ((nd/is-project-p)
nil) ;; nil)
((and (nd/is-subtask-p) (not (nd/is-atomic-p))) ;; ((and (nd/is-subtask-p) (not (nd/is-atomic-p)))
nil) ;; nil)
(t ;; (t
subtree-end)))) ;; subtree-end))))
(save-excursion (org-end-of-subtree t)))) ;; (save-excursion (org-end-of-subtree t))))
(defun nd/skip-non-tasks () (defun nd/skip-non-tasks ()
"Show non-project tasks. "Show non-project tasks.