diff --git a/etc/conf.org b/etc/conf.org index 4276f7e..ca6c6cf 100644 --- a/etc/conf.org +++ b/etc/conf.org @@ -3055,7 +3055,7 @@ In the order of display (interactive) (let ((f (list (org-x-get-endpoint-goal-file)))) (org-x-update-goal-link-ids) - (nd/org-agenda-call "Ranked Goals" nil 'todo org-x-kw-todo f + (nd/org-agenda-call "Ranked EPGs" nil 'todo org-x-kw-todo f `((org-agenda-sorting-strategy '(priority-down time-up)) (org-super-agenda-groups ',(nd/org-def-super-agenda-automap @@ -3063,6 +3063,20 @@ In the order of display (format "Score: %s" score) "No Score"))))))) +(defun nd/org-agenda-ranked-lifetime-goals () + "Show the ranked endpoint goals agenda view." + (interactive) + (let ((f (list (org-x-get-lifetime-goal-file)))) + (org-x-update-goal-link-ids) + (nd/org-agenda-call "Ranked LTGs" nil 'todo org-x-kw-todo f + `((org-agenda-sorting-strategy '(priority-down time-up)) + (org-super-agenda-groups + ',(nd/org-def-super-agenda-automap + ;; TODO not DRY + (-when-let (c (org-x-headline-get-category-tag)) + (let ((n (alist-get c org-x--quarter-life-categories nil nil #'equal))) + (format "%s. %s" n (or (-some->> c (s-chop-prefix "_")) "NA")))))))))) + ;; TODO this is slow and the code isn't pretty to look at, perhaps break into ;; several agenda views, or at least refactor the common bits (defun nd/org-agenda-goal-groups () diff --git a/local/lib/org-x/org-x.el b/local/lib/org-x/org-x.el index 6399ddb..3c0c44b 100644 --- a/local/lib/org-x/org-x.el +++ b/local/lib/org-x/org-x.el @@ -1288,6 +1288,19 @@ Assumes point is on a valid headline or org mode file." (org-x-qt-plan-get-categories) (setq org-x--quarter-life-categories))) +(defun org-x-headline-get-category-tag () + (--find (s-prefix-p "_" it) (org-get-tags))) + +(defun org-x-get-category-score () + (-when-let (c (org-x-headline-get-category-tag)) + (alist-get c org-x--quarter-life-categories nil nil #'equal))) + +(defun org-x-lifetime-goal-get-score () + (let* ((p (aref (org-entry-get nil "PRIORITY") 0)) + (priority-score (if (= org-priority-highest p) 1 -1))) + (-when-let (cat-score (org-x-get-category-score)) + (* cat-score priority-score)))) + (defun org-x-endpoint-goal-get-score () (unless org-x--quarter-life-categories (error "`org-x--quarter-life-categories' is not set")) @@ -1296,12 +1309,7 @@ Assumes point is on a valid headline or org mode file." (link) (let ((id (org-ml-get-property :path link))) (org-x-with-id-target id - (let* ((p (aref (org-entry-get nil "PRIORITY") 0)) - (c (--find (s-prefix-p "_" it) (org-get-tags))) - (priority-score (if (= org-priority-highest p) 1 -1)) - (cat-score (alist-get c org-x--quarter-life-categories - nil nil #'equal))) - (* cat-score priority-score)))))) + (org-x-lifetime-goal-get-score))))) (-some->> (org-x-get-goal-link-property) (-map #'get-link-score) (-sum))))