feat(org): make Roam tasks inherit areas and goals

This commit is contained in:
Kiana Sheibani 2024-08-14 05:11:28 -04:00
parent 50ed195193
commit a5c2996c9a
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -3342,13 +3342,15 @@ Areas are stored as subnodes of the =Areas= file node, and likewise for goals. T
#+begin_src emacs-lisp
(defun ~/org-roam-get-linked-nodes (node tag)
"Return the nodes that NODE links to that are tagged with TAG."
(unless (stringp node)
(setq node (org-roam-node-id node)))
(let ((response (org-roam-db-query [:select :distinct [dest]
:from links
:inner-join tags :on (= dest node_id)
:where (= source $s1)
:and (= type "id")
:and (= tag $s2)]
(org-roam-node-id node) tag)))
node tag)))
(mapcar (lambda (id) (org-roam-populate
(org-roam-node-create :id (car id))))
response)))
@ -3612,9 +3614,12 @@ By customizing ~org-super-agenda-groups~ via a let-binding in my custom agenda v
(defun ~/org-agenda-section-by-link (prefix tag item)
"Org super-agenda function to categorize agenda entries by linked node with TAG."
(when-let* ((marker (org-super-agenda--get-marker item))
(node (org-super-agenda--when-with-marker-buffer marker
(org-roam-node-at-point)))
(links (~/org-roam-get-linked-nodes node tag)))
(nodes (org-super-agenda--when-with-marker-buffer marker
(--keep (org-element-property :ID it)
(org-element-lineage (org-element-context) nil t))))
(-compare-fn (lambda (a b)
(equal (org-roam-node-id a) (org-roam-node-id b))))
(links (-distinct (--mapcat (~/org-roam-get-linked-nodes it tag) nodes))))
(->> links
(mapcar #'org-roam-node-title)
(-interpose ", ")