REF make todo keywords DRY
This commit is contained in:
parent
a8a7ecb584
commit
3be64ee7ec
|
@ -36,6 +36,25 @@
|
||||||
(require 'org)
|
(require 'org)
|
||||||
(require 'org-x-agg)
|
(require 'org-x-agg)
|
||||||
|
|
||||||
|
;;; TODO KEYWORDS
|
||||||
|
|
||||||
|
(defconst org-x-kw-todo "TODO"
|
||||||
|
"Headline todo keyword for open task or project.")
|
||||||
|
|
||||||
|
(defconst org-x-kw-next "NEXT"
|
||||||
|
"Headline todo keyword for next task.")
|
||||||
|
|
||||||
|
(defconst org-x-kw-wait "WAIT"
|
||||||
|
"Headline todo keyword for task that is waiting on something.")
|
||||||
|
|
||||||
|
(defconst org-x-kw-hold "HOLD"
|
||||||
|
"Headline todo keyword for task or project that is held.")
|
||||||
|
|
||||||
|
(defconst org-x-kw-done "DONE"
|
||||||
|
"Headline todo keyword for completed task or project.")
|
||||||
|
|
||||||
|
(defconst org-x-kw-canc "CANC"
|
||||||
|
"Headline todo keyword for cancelled task or project.")
|
||||||
|
|
||||||
;;; TAGS
|
;;; TAGS
|
||||||
|
|
||||||
|
@ -203,15 +222,15 @@
|
||||||
"The number of days to wait before tasks are considered inert.")
|
"The number of days to wait before tasks are considered inert.")
|
||||||
|
|
||||||
(defconst org-x-project-invalid-todostates
|
(defconst org-x-project-invalid-todostates
|
||||||
'("WAIT" "NEXT")
|
(list org-x-kw-wait org-x-kw-next)
|
||||||
"Projects cannot have these todostates.")
|
"Projects cannot have these todostates.")
|
||||||
|
|
||||||
(defconst org-x-agenda-todo-sort-order
|
(defconst org-x-agenda-todo-sort-order
|
||||||
'("NEXT" "WAIT" "HOLD" "TODO")
|
(list org-x-kw-next org-x-kw-wait org-x-kw-hold org-x-kw-todo)
|
||||||
"Defines the order in which todo keywords should be sorted.")
|
"Defines the order in which todo keywords should be sorted.")
|
||||||
|
|
||||||
(defconst org-x-project-skip-todostates
|
(defconst org-x-project-skip-todostates
|
||||||
'("HOLD" "CANC")
|
'(org-x-kw-hold org-x-kw-canc)
|
||||||
"These keywords override all contents within their subtrees.
|
"These keywords override all contents within their subtrees.
|
||||||
Currently used to tell skip functions when they can hop over
|
Currently used to tell skip functions when they can hop over
|
||||||
entire subtrees to save time and ignore tasks")
|
entire subtrees to save time and ignore tasks")
|
||||||
|
@ -564,7 +583,7 @@ should be this function again)."
|
||||||
(cond
|
(cond
|
||||||
;; held projects do not care what is underneath them
|
;; held projects do not care what is underneath them
|
||||||
;; only need to test if they are inert
|
;; only need to test if they are inert
|
||||||
((equal keyword "HOLD") (if (org-x-is-inert-p) :inert :held))
|
((equal keyword org-x-kw-hold) (if (org-x-is-inert-p) :inert :held))
|
||||||
|
|
||||||
;; projects with invalid todostates are nonsense
|
;; projects with invalid todostates are nonsense
|
||||||
((member keyword org-x-project-invalid-todostates)
|
((member keyword org-x-project-invalid-todostates)
|
||||||
|
@ -572,7 +591,7 @@ should be this function again)."
|
||||||
|
|
||||||
;; canceled projects can either be archivable or complete
|
;; canceled projects can either be archivable or complete
|
||||||
;; any errors or undone tasks are irrelevant
|
;; any errors or undone tasks are irrelevant
|
||||||
((equal keyword "CANC") (if (org-x-is-archivable-heading-p) :archivable
|
((equal keyword org-x-kw-canc) (if (org-x-is-archivable-heading-p) :archivable
|
||||||
:complete))
|
:complete))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -580,7 +599,7 @@ should be this function again)."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; done projects are like canceled projects but can also be incomplete
|
;; done projects are like canceled projects but can also be incomplete
|
||||||
((equal keyword "DONE")
|
((equal keyword org-x-kw-done)
|
||||||
(org-x-descend-into-project
|
(org-x-descend-into-project
|
||||||
((:archivable)
|
((:archivable)
|
||||||
(:complete)
|
(:complete)
|
||||||
|
@ -593,7 +612,7 @@ should be this function again)."
|
||||||
org-x-get-project-status))
|
org-x-get-project-status))
|
||||||
|
|
||||||
;; project with TODO states could be basically any status
|
;; project with TODO states could be basically any status
|
||||||
((equal keyword "TODO")
|
((equal keyword org-x-kw-todo)
|
||||||
(org-x-descend-into-project
|
(org-x-descend-into-project
|
||||||
((:undone-complete :complete :archivable)
|
((:undone-complete :complete :archivable)
|
||||||
(:stuck :scheduled-project :invalid-todostate :done-incomplete)
|
(:stuck :scheduled-project :invalid-todostate :done-incomplete)
|
||||||
|
@ -603,10 +622,10 @@ should be this function again)."
|
||||||
(:active))
|
(:active))
|
||||||
(cond
|
(cond
|
||||||
((and (not (member it-kw org-done-keywords)) (org-x-is-inert-p)) 4)
|
((and (not (member it-kw org-done-keywords)) (org-x-is-inert-p)) 4)
|
||||||
((equal it-kw "TODO") (if (org-x-is-scheduled-heading-p) 5 1))
|
((equal it-kw org-x-kw-todo) (if (org-x-is-scheduled-heading-p) 5 1))
|
||||||
((equal it-kw "HOLD") 2)
|
((equal it-kw org-x-kw-hold) 2)
|
||||||
((equal it-kw "WAIT") 3)
|
((equal it-kw org-x-kw-wait) 3)
|
||||||
((equal it-kw "NEXT") 5)
|
((equal it-kw org-x-kw-next) 5)
|
||||||
(t 0))
|
(t 0))
|
||||||
org-x-get-project-status))
|
org-x-get-project-status))
|
||||||
|
|
||||||
|
@ -620,7 +639,7 @@ should be this function again)."
|
||||||
(member kw org-x-project-invalid-todostates)) :project-error)
|
(member kw org-x-project-invalid-todostates)) :project-error)
|
||||||
|
|
||||||
;; canceled tasks add nothing
|
;; canceled tasks add nothing
|
||||||
((equal kw "CANC") :empt)
|
((equal kw org-x-kw-canc) :empt)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; these require descending into the project subtasks
|
;; these require descending into the project subtasks
|
||||||
|
@ -628,7 +647,7 @@ should be this function again)."
|
||||||
|
|
||||||
;; done projects either add nothing (empty) or are not actually
|
;; done projects either add nothing (empty) or are not actually
|
||||||
;; done (project error)
|
;; done (project error)
|
||||||
((equal kw "DONE")
|
((equal kw org-x-kw-done)
|
||||||
(org-x-descend-into-project
|
(org-x-descend-into-project
|
||||||
((:empt)
|
((:empt)
|
||||||
(:project-error :unscheduled :actv))
|
(:project-error :unscheduled :actv))
|
||||||
|
@ -636,7 +655,7 @@ should be this function again)."
|
||||||
org-x--clone-get-iterator-project-status))
|
org-x--clone-get-iterator-project-status))
|
||||||
|
|
||||||
;; project with TODO states could be basically any status
|
;; project with TODO states could be basically any status
|
||||||
((equal kw "TODO")
|
((equal kw org-x-kw-todo)
|
||||||
(org-x-descend-into-project
|
(org-x-descend-into-project
|
||||||
((:unscheduled :project-error)
|
((:unscheduled :project-error)
|
||||||
(:empt)
|
(:empt)
|
||||||
|
@ -769,7 +788,7 @@ This includes unchecking all checkboxes, marking keywords as
|
||||||
((reset
|
((reset
|
||||||
(config created-ts headline)
|
(config created-ts headline)
|
||||||
(->> (if (org-ml-headline-is-done headline)
|
(->> (if (org-ml-headline-is-done headline)
|
||||||
(org-ml-set-property :todo-keyword "TODO" headline)
|
(org-ml-set-property :todo-keyword org-x-kw-todo headline)
|
||||||
headline)
|
headline)
|
||||||
(org-ml-headline-map-supercontents* config
|
(org-ml-headline-map-supercontents* config
|
||||||
(org-ml-supercontents-set-logbook nil it))
|
(org-ml-supercontents-set-logbook nil it))
|
||||||
|
@ -893,7 +912,7 @@ don't log changes in the logbook."
|
||||||
(defun org-x-mark-subtree-done ()
|
(defun org-x-mark-subtree-done ()
|
||||||
"Mark all tasks in subtree as DONE unless they are already CANC."
|
"Mark all tasks in subtree as DONE unless they are already CANC."
|
||||||
(interactive)
|
(interactive)
|
||||||
(org-x-mark-subtree-keyword "DONE" '("CANC")))
|
(org-x-mark-subtree-keyword org-x-kw-done `(,org-x-kw-canc)))
|
||||||
|
|
||||||
;; logbook
|
;; logbook
|
||||||
|
|
||||||
|
@ -968,7 +987,7 @@ and slow."
|
||||||
(-)))
|
(-)))
|
||||||
(headline*
|
(headline*
|
||||||
(->> (org-ml-clone-node headline)
|
(->> (org-ml-clone-node headline)
|
||||||
(org-ml-set-property :todo-keyword "DONE")
|
(org-ml-set-property :todo-keyword org-x-kw-done)
|
||||||
(org-ml-headline-map-planning*
|
(org-ml-headline-map-planning*
|
||||||
(let ((time (->> (float-time)
|
(let ((time (->> (float-time)
|
||||||
(org-ml-unixtime-to-time-long))))
|
(org-ml-unixtime-to-time-long))))
|
||||||
|
|
Loading…
Reference in New Issue