ADD incubator scanner

This commit is contained in:
Nathan Dwarshuis 2022-01-23 12:01:41 -05:00
parent 4cfae73ca2
commit 2c717aa050
2 changed files with 82 additions and 49 deletions

View File

@ -102,7 +102,7 @@ that file as it currently sits on disk.")
;; ))
`(,(org-x-get-lifetime-goal-file)
,(org-x-get-endpoint-goal-file)
,@(org-x-get-action-files)))
,@(org-x-get-action-and-incubator-files)))
(defun org-x-dag-get-md5 (path)
"Get the md5 checksum of PATH."
@ -214,10 +214,14 @@ valid keyword or none of its parents have valid keywords."
(when (= ?* (following-char))
(setq this-point (point)
this-key nil)
;; TODO this might be optimizable
;; Get tags (must be done from the first column)
(setq this-tags (org--get-local-tags))
;; Get the level
;; Get the level if the following char is a space (if it isn't this is
;; actually a bolded object that starts on the first column like
;; '*blabla*'
(while (= ?* (following-char)) (forward-char 1))
(when (= 32 (following-char))
(setq this-level (current-column))
;; Check if the headline has a keyword
(forward-char 1)
@ -249,9 +253,11 @@ valid keyword or none of its parents have valid keywords."
tags
toplevelp))
(!cons (cons this-key this-meta) acc-meta)
(!cons (cons this-key (-some-> (nth 1 this-parent) (list))) acc))
(!cons (cons this-key (append (list (nth 1 this-parent))
(org-x-dag-get-link-property)))
acc))
;; Add current headline to stack
(!cons (list this-level this-key this-tags) cur-path))
(!cons (list this-level this-key this-tags) cur-path)))
(setq more (= 0 (forward-line 1))))
;; TODO reverse these to make things make sense later?
(list acc acc-meta)))
@ -960,23 +966,50 @@ encountered will be returned."
'x-status s)))))))))
(org-x-dag-with-files (org-x-get-action-files)
(org-x-dag-id->is-toplevel-p it)
;; TODO this is firing for each key, probably not necessary but whatever,
;; not that slow
(let ((category (org-get-category)))
(-if-let (project-tasks (org-x-dag-get-task-nodes it))
(--map (format-key category nil it) project-tasks)
(list (format-key category t it)))))))
;; (defun org-x-dag-scan-tags ()
;; (let* ((dag org-x-dag)
;; (nodes (org-x-dag-get-toplevel-project-nodes dag)))
;; (->> (--group-by (org-x-dag-key-get-file (car it)) nodes)
;; (--mapcat
;; (-let (((path . nodes) it))
;; (org-x-with-file path
;; (->> (-map #'car nodes)
;; (--mapcat
;; (progn
;; (goto-char (org-x-dag-key-get-point it))
;; (org-x-dag-format-tag-node dag (org-get-tags (point)) it))))))))))
;; (defun org-x-dag-partition-children (ids)
;; (cl-labels
;; ((descend
;; (acc children)
;; (-let (((projects tasks) acc))
;; (->> (--remove (member (org-x-dag-id-lookup-prop it :todo)
;; (list org-x-kw-canc org-x-kw-hold))
;; children)
;; (--mapcat (-if-let (cs (org-x-dag-id->headline-children it))
;; (descend `((it ,@projects) (,@tasks)) cs)
;; `((,@projects) (it ,@tasks))))))))
;; (-reduce-from #'descend nil ids)))
(defun org-x-dag-scan-incubated ()
(cl-flet
((format-key
(category key)
(let ((tags (->> (org-x-dag-get-inherited-tags org-file-tags
(plist-get org-x-dag :dag)
key)
(append (org-x-dag-id-lookup-prop key :tags))
(org-x-dag-collapse-tags))))
(when (member org-x-tag-incubated tags)
(org-x-dag-with-key key
(let* ((sch (org-x-headline-is-scheduled t))
(dead (org-x-headline-is-deadlined t))
(is-project (org-x-dag-id->headline-children key)))
(-> (org-x-dag-format-tag-node category tags key)
(org-add-props nil
'x-project-p is-project
'x-scheduled sch
'x-deadlined dead))))))))
(org-x-dag-with-files (org-x-get-action-and-incubator-files)
(and (org-x-dag-id->is-toplevel-p it)
(not (member (org-x-dag-id-lookup-prop it :todo) org-x-done-keywords)))
(let ((category (org-get-category)))
(list (format-key category it))))))
(defun org-x-dag-get-inherited-tags (init dag key)
(let* ((this-file (org-x-dag-key-get-file key)))

View File

@ -2083,7 +2083,7 @@ This includes unchecking all checkboxes, marking keywords as
(org-ml-headline-map-planning*
(-some->> it (org-ml-planning-set-timestamp! :closed nil)))
;; remove ID property
(org-ml-headline-set-node-property "ID" nil)
(org-ml-headline-set-node-property "ID" (org-id-new))
;; clear item checkboxes
(org-ml-match-map* '(section :any * item)
(org-ml-set-property :checkbox 'off it))