ADD agenda view for projects linked to goals
This commit is contained in:
parent
f58d0bc605
commit
021b246e4b
|
@ -317,6 +317,23 @@ that file as it currently sits on disk.")
|
||||||
(->> (plist-get org-x-dag :dag)
|
(->> (plist-get org-x-dag :dag)
|
||||||
(dag-get-parents id)))
|
(dag-get-parents id)))
|
||||||
|
|
||||||
|
(defun org-x-dag-id->split-parents (id)
|
||||||
|
(let ((ps (org-x-dag-id->parents id)))
|
||||||
|
(if (org-x-dag-id->is-toplevel-p id)
|
||||||
|
`(nil ,ps)
|
||||||
|
(let ((f (org-x-dag-id->file id)))
|
||||||
|
;; ASSUME there will only be one headline parent (not sure how that
|
||||||
|
;; wouldn't be true, but this algorithm doesn't care or know)
|
||||||
|
(-if-let (i (--find-index (equal f (org-x-dag-id->file it)) ps))
|
||||||
|
`(,(nth i ps) ,(-remove-at i ps))
|
||||||
|
`(nil ,ps))))))
|
||||||
|
|
||||||
|
(defun org-x-dag-id->headline-parent (id)
|
||||||
|
(car (org-x-dag-id->split-parents id)))
|
||||||
|
|
||||||
|
(defun org-x-dag-id->foreign-parents (id)
|
||||||
|
(cadr (org-x-dag-id->split-parents id)))
|
||||||
|
|
||||||
(defun org-x-dag-id->children (id)
|
(defun org-x-dag-id->children (id)
|
||||||
(->> (plist-get org-x-dag :dag)
|
(->> (plist-get org-x-dag :dag)
|
||||||
(dag-get-children id)))
|
(dag-get-children id)))
|
||||||
|
@ -886,6 +903,12 @@ A date like (YEAR MONTH DAY).")
|
||||||
(cadr)))))
|
(cadr)))))
|
||||||
|
|
||||||
(defun org-x-dag-get-parent-links ()
|
(defun org-x-dag-get-parent-links ()
|
||||||
|
(cl-flet
|
||||||
|
((match-id
|
||||||
|
(s)
|
||||||
|
(->> (s-match "id:\\([^][]\\{36\\}\\)" s)
|
||||||
|
(cadr)
|
||||||
|
(substring-no-properties))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((re (concat
|
(let ((re (concat
|
||||||
"^[ \t]*:X_PARENT_LINKS:[ \t]*\n"
|
"^[ \t]*:X_PARENT_LINKS:[ \t]*\n"
|
||||||
|
@ -895,7 +918,7 @@ A date like (YEAR MONTH DAY).")
|
||||||
(-some->> (and (re-search-forward re end t) (match-string 1))
|
(-some->> (and (re-search-forward re end t) (match-string 1))
|
||||||
(s-trim)
|
(s-trim)
|
||||||
(s-split "\n")
|
(s-split "\n")
|
||||||
(--map (cadr (s-match "id:\\([^][]\\{36\\}\\)" it)))))))
|
(-map #'match-id))))))
|
||||||
|
|
||||||
(defun org-x-dag-line-regexp (kws)
|
(defun org-x-dag-line-regexp (kws)
|
||||||
(let ((level-re "\\(\\*+\\)")
|
(let ((level-re "\\(\\*+\\)")
|
||||||
|
@ -1694,8 +1717,8 @@ FUTURE-LIMIT in a list."
|
||||||
((split-parent-goals
|
((split-parent-goals
|
||||||
(s)
|
(s)
|
||||||
(let ((id (get-text-property 1 'x-id s)))
|
(let ((id (get-text-property 1 'x-id s)))
|
||||||
(-if-let (goal-ids (org-x-dag-id->goals id))
|
(-if-let (goal-ids (org-x-dag-id->foreign-parents id))
|
||||||
(--map (org-add-props s nil 'x-goal-id it) goal-ids)
|
(--map (org-add-props (copy-seq s) nil 'x-goal-id it) goal-ids)
|
||||||
(list (org-add-props s nil 'x-goal-id nil))))))
|
(list (org-add-props s nil 'x-goal-id nil))))))
|
||||||
(->> (org-x-dag-scan-projects)
|
(->> (org-x-dag-scan-projects)
|
||||||
(--filter (org-x-dag-id->is-toplevel-p (get-text-property 1 'x-id it)))
|
(--filter (org-x-dag-id->is-toplevel-p (get-text-property 1 'x-id it)))
|
||||||
|
@ -1775,7 +1798,9 @@ FUTURE-LIMIT in a list."
|
||||||
((split-parent-goals
|
((split-parent-goals
|
||||||
(s)
|
(s)
|
||||||
(let ((id (get-text-property 1 'x-id s)))
|
(let ((id (get-text-property 1 'x-id s)))
|
||||||
(-if-let (goal-ids (org-x-dag-id->goals id))
|
;; ASSUME all foreign parents are actually goals
|
||||||
|
;; TODO this isn't a great assumption
|
||||||
|
(-if-let (goal-ids (org-x-dag-id->foreign-parents id))
|
||||||
(--map (org-add-props s nil 'x-goal-id it) goal-ids)
|
(--map (org-add-props s nil 'x-goal-id it) goal-ids)
|
||||||
(list (org-add-props s nil 'x-goal-id nil))))))
|
(list (org-add-props s nil 'x-goal-id nil))))))
|
||||||
(->> (org-x-dag-scan-tasks)
|
(->> (org-x-dag-scan-tasks)
|
||||||
|
|
Loading…
Reference in New Issue