updated periodicals

This commit is contained in:
petrucci4prez 2018-06-26 22:59:47 -04:00
parent ec131bc5b5
commit 103611d026
2 changed files with 106 additions and 68 deletions

78
conf.el
View File

@ -731,6 +731,31 @@ todoitem which in turn has a parent which is a todoitem"
(outline-next-heading))) (outline-next-heading)))
iter-status)) iter-status))
(defconst nd/peri-future-time nd/iter-future-time)
(defconst nd/peri-statuscodes '(:uninit :stale :fresh))
(defun nd/get-periodical-status ()
(let ((peri-status :uninit)
(subtree-end (save-excursion (org-end-of-subtree t))))
(save-excursion
(setq previous-point (point))
(outline-next-heading)
(while (and (not (eq peri-status :fresh))
(< (point) subtree-end))
(if (and (nd/is-periodical-heading-p)
(not (nd/heading-has-children 'nd/is-periodical-heading-p)))
(let ((new-status
(if (nd/heading-compare-timestamp
'nd/is-timestamped-heading-p
nd/iter-future-time t)
:fresh
:stale)))
(if (nd/compare-statuscodes > new-status peri-status nd/peri-statuscodes)
(setq peri-status new-status))))
(outline-next-heading)))
peri-status))
(defun nd/skip-heading () (defun nd/skip-heading ()
(save-excursion (or (outline-next-heading) (point-max)))) (save-excursion (or (outline-next-heading) (point-max))))
@ -799,29 +824,19 @@ tags that do not have tags in neg-tags-list"
(and (member keyword org-done-keywords) (and (member keyword org-done-keywords)
(nd/is-archivable-heading-p)))) (nd/is-archivable-heading-p))))
(defun nd/skip-non-fresh-periodical-parent-headers () (defun nd/skip-non-periodical-parent-headers ()
(save-restriction (save-restriction
(widen) (widen)
(if (not (and (nd/is-periodical-heading-p) (if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p)) (not (nd/heading-has-parent 'nd/is-periodical-heading-p))))
(nd/heading-has-children 'nd/is-fresh-heading-p)))
(nd/skip-heading)))) (nd/skip-heading))))
(defun nd/skip-non-stale-periodical-parent-headers () (defun nd/skip-non-periodical-untimestamped ()
(save-restriction (save-restriction
(widen) (widen)
(if (not (and (nd/is-periodical-heading-p) (if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p)) (not (nd/is-timestamped-heading-p))
(nd/heading-has-children 'nd/is-stale-heading-p) (not (nd/heading-has-children 'nd/is-periodical-heading-p))))
(not (nd/heading-has-children 'nd/is-fresh-heading-p))))
(nd/skip-heading))))
(defun nd/skip-non-empty-periodical-parent-headers ()
(save-restriction
(widen)
(if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p))
(not (nd/heading-has-children 'nd/is-timestamped-heading-p))))
(nd/skip-heading)))) (nd/skip-heading))))
(defun nd/skip-non-iterator-parent-headers () (defun nd/skip-non-iterator-parent-headers ()
@ -1049,15 +1064,21 @@ set as a text property for further sorting"
("P" ("P"
"Periodical View" "Periodical View"
(,(nd/agenda-base-header-cmd peri-match ((tags
"Empty Periodicals" "-NA-REFILE+PARENT_TYPE=\"periodical\""
''nd/skip-non-empty-periodical-parent-headers) ((org-agenda-overriding-header "Periodical Status")
,(nd/agenda-base-header-cmd peri-match (org-agenda-skip-function '(nd/skip-non-periodical-parent-headers))
"Stale Periodicals" (org-agenda-before-sorting-filter-function
''nd/skip-non-stale-periodical-parent-headers) (lambda (l) (nd/org-agenda-filter-status
,(nd/agenda-base-header-cmd peri-match nd/peri-statuscodes 'nd/get-periodical-status l)))
"Fresh Periodicals" (org-agenda-cmp-user-defined
''nd/skip-non-fresh-periodical-parent-headers))) (lambda (a b) (nd/org-agenda-sort-prop
'project-status nd/peri-statuscodes a b)))
(org-agenda-prefix-format '((tags . " %-12:c %(format \"xxxx: \")")))
(org-agenda-sorting-strategy '(user-defined-down category-keep))))
,(nd/agenda-base-header-cmd "-NA-REFILE+PARENT_TYPE=\"periodical\""
"Untimestamped"
''nd/skip-non-periodical-untimestamped)))
("i" ("i"
"Iterator View" "Iterator View"
@ -1124,14 +1145,11 @@ set as a text property for further sorting"
("A" ("A"
"Archivable Tasks and Projects" "Archivable Tasks and Projects"
(,(nd/agenda-base-header-cmd (concat actionable "-" periodical) (,(nd/agenda-base-header-cmd (concat actionable "-" periodical)
"Archivable Atomic Tasks" "Archivable Atomic Tasks and Iterators"
''nd/skip-non-archivable-atomic-tasks) ''nd/skip-non-archivable-atomic-tasks)
,(nd/agenda-base-header-cmd (concat actionable "-" periodical) ,(nd/agenda-base-header-cmd (concat actionable)
"Stale Tasks" "Stale Tasks and Periodicals"
''nd/skip-non-stale-headings) ''nd/skip-non-stale-headings)
,(nd/agenda-base-header-cmd (concat actionable "-" periodical "+" iterator)
"Archivable Iterators"
''nd/skip-non-archivable-atomic-tasks)
(tags-todo (tags-todo
,(concat actionable "-" periodical "-" iterator) ,(concat actionable "-" periodical "-" iterator)
((org-agenda-overriding-header ((org-agenda-overriding-header

View File

@ -962,6 +962,33 @@ Returns t if heading has certain relationship to other headings
(outline-next-heading))) (outline-next-heading)))
iter-status)) iter-status))
#+END_SRC #+END_SRC
**** periodical testing
#+BEGIN_SRC emacs-lisp
(defconst nd/peri-future-time nd/iter-future-time)
(defconst nd/peri-statuscodes '(:uninit :stale :fresh))
(defun nd/get-periodical-status ()
(let ((peri-status :uninit)
(subtree-end (save-excursion (org-end-of-subtree t))))
(save-excursion
(setq previous-point (point))
(outline-next-heading)
(while (and (not (eq peri-status :fresh))
(< (point) subtree-end))
(if (and (nd/is-periodical-heading-p)
(not (nd/heading-has-children 'nd/is-periodical-heading-p)))
(let ((new-status
(if (nd/heading-compare-timestamp
'nd/is-timestamped-heading-p
nd/iter-future-time t)
:fresh
:stale)))
(if (nd/compare-statuscodes > new-status peri-status nd/peri-statuscodes)
(setq peri-status new-status))))
(outline-next-heading)))
peri-status))
#+END_SRC
*** skip functions *** skip functions
These are the primary means we use to sort through tasks. Note that we could do this with These are the primary means we use to sort through tasks. Note that we could do this with
tags in the custom commands section but I find this easier to maintain and possibly faster. tags in the custom commands section but I find this easier to maintain and possibly faster.
@ -1065,29 +1092,19 @@ simply because they have timestamps. Parents can be
either fresh (at least one child in the future) or either fresh (at least one child in the future) or
stale (all children in the past). stale (all children in the past).
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun nd/skip-non-fresh-periodical-parent-headers () (defun nd/skip-non-periodical-parent-headers ()
(save-restriction (save-restriction
(widen) (widen)
(if (not (and (nd/is-periodical-heading-p) (if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p)) (not (nd/heading-has-parent 'nd/is-periodical-heading-p))))
(nd/heading-has-children 'nd/is-fresh-heading-p)))
(nd/skip-heading)))) (nd/skip-heading))))
(defun nd/skip-non-stale-periodical-parent-headers () (defun nd/skip-non-periodical-untimestamped ()
(save-restriction (save-restriction
(widen) (widen)
(if (not (and (nd/is-periodical-heading-p) (if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p)) (not (nd/is-timestamped-heading-p))
(nd/heading-has-children 'nd/is-stale-heading-p) (not (nd/heading-has-children 'nd/is-periodical-heading-p))))
(not (nd/heading-has-children 'nd/is-fresh-heading-p))))
(nd/skip-heading))))
(defun nd/skip-non-empty-periodical-parent-headers ()
(save-restriction
(widen)
(if (not (and (nd/is-periodical-heading-p)
(not (nd/heading-has-parent 'nd/is-periodical-heading-p))
(not (nd/heading-has-children 'nd/is-timestamped-heading-p))))
(nd/skip-heading)))) (nd/skip-heading))))
#+END_SRC #+END_SRC
**** iterators **** iterators
@ -1348,15 +1365,21 @@ set as a text property for further sorting"
("P" ("P"
"Periodical View" "Periodical View"
(,(nd/agenda-base-header-cmd peri-match ((tags
"Empty Periodicals" "-NA-REFILE+PARENT_TYPE=\"periodical\""
''nd/skip-non-empty-periodical-parent-headers) ((org-agenda-overriding-header "Periodical Status")
,(nd/agenda-base-header-cmd peri-match (org-agenda-skip-function '(nd/skip-non-periodical-parent-headers))
"Stale Periodicals" (org-agenda-before-sorting-filter-function
''nd/skip-non-stale-periodical-parent-headers) (lambda (l) (nd/org-agenda-filter-status
,(nd/agenda-base-header-cmd peri-match nd/peri-statuscodes 'nd/get-periodical-status l)))
"Fresh Periodicals" (org-agenda-cmp-user-defined
''nd/skip-non-fresh-periodical-parent-headers))) (lambda (a b) (nd/org-agenda-sort-prop
'project-status nd/peri-statuscodes a b)))
(org-agenda-prefix-format '((tags . " %-12:c %(format \"xxxx: \")")))
(org-agenda-sorting-strategy '(user-defined-down category-keep))))
,(nd/agenda-base-header-cmd "-NA-REFILE+PARENT_TYPE=\"periodical\""
"Untimestamped"
''nd/skip-non-periodical-untimestamped)))
("i" ("i"
"Iterator View" "Iterator View"
@ -1423,14 +1446,11 @@ set as a text property for further sorting"
("A" ("A"
"Archivable Tasks and Projects" "Archivable Tasks and Projects"
(,(nd/agenda-base-header-cmd (concat actionable "-" periodical) (,(nd/agenda-base-header-cmd (concat actionable "-" periodical)
"Archivable Atomic Tasks" "Archivable Atomic Tasks and Iterators"
''nd/skip-non-archivable-atomic-tasks) ''nd/skip-non-archivable-atomic-tasks)
,(nd/agenda-base-header-cmd (concat actionable "-" periodical) ,(nd/agenda-base-header-cmd (concat actionable)
"Stale Tasks" "Stale Tasks and Periodicals"
''nd/skip-non-stale-headings) ''nd/skip-non-stale-headings)
,(nd/agenda-base-header-cmd (concat actionable "-" periodical "+" iterator)
"Archivable Iterators"
''nd/skip-non-archivable-atomic-tasks)
(tags-todo (tags-todo
,(concat actionable "-" periodical "-" iterator) ,(concat actionable "-" periodical "-" iterator)
((org-agenda-overriding-header ((org-agenda-overriding-header