REF rewrite iterator and periodical status functions with while macro

This commit is contained in:
Nathan Dwarshuis 2021-04-18 18:41:43 -04:00
parent 71c9cdceb1
commit cf2b63e276
1 changed files with 23 additions and 37 deletions

View File

@ -708,19 +708,13 @@ Allowed statuscodes are in list `nd/get-iter-statuscodes.' where
latter codes in the list trump earlier ones."
(let ((cur-status (first org-x-iter-statuscodes))
(breaker-status (-last-item org-x-iter-statuscodes))
(subtree-end (save-excursion (org-end-of-subtree t)))
(prev-point (point))
(kw nil)
(new-status nil)
(ts nil))
(save-excursion
(outline-next-heading)
(while (and (not (eq cur-status breaker-status))
(< prev-point (point) subtree-end))
(setq kw (org-x-is-todoitem-p)
new-status nil)
(org-x-while-child-headlines (not (eq cur-status breaker-status))
(setq kw (org-x-is-todoitem-p))
(when kw
;; test if project of atomic task
;; test if project or atomic task
;; assume that there are no todoitems above this headline
;; to make checking easier
(setq
@ -735,9 +729,7 @@ Allowed statuscodes are in list `nd/get-iter-statuscodes.' where
((< org-x-iter-future-time (- ts (float-time))) :actv)
(t :empt))))
(when (org-x-compare-statuscodes > new-status cur-status org-x-iter-statuscodes)
(setq cur-status new-status)))
(setq prev-point (point))
(org-forward-heading-same-level 1 t)))
(setq cur-status new-status))))
cur-status))
;; periodicals
@ -767,16 +759,9 @@ latter codes in the list trump earlier ones."
new
cur-status))))
(let ((cur-status (first org-x-peri-statuscodes))
(breaker-status (-last-item org-x-peri-statuscodes))
(subtree-end (save-excursion (org-end-of-subtree t)))
(prev-point (point)))
(save-excursion
(outline-next-heading)
(while (and (not (eq cur-status breaker-status))
(< prev-point (point) subtree-end))
(setq cur-status (->> (get-ts) (new-status cur-status)))
(setq prev-point (point))
(org-forward-heading-same-level 1 t)))
(breaker-status (-last-item org-x-peri-statuscodes)))
(org-x-while-child-headlines (not (eq cur-status breaker-status))
(setq cur-status (->> (get-ts) (new-status cur-status))))
cur-status)))
;; skip functions
@ -922,6 +907,7 @@ N is the number of clones to produce."
;; marking subtrees
;; put this in terms of org-ml
(defun org-x-mark-subtree-keyword (new-keyword &optional exclude no-log)
"Change the todo keyword of all tasks in a subtree to NEW-KEYWORD.
If EXCLUDE is given, it should be a list of todo keywords; any headline