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 #+begin_src emacs-lisp
(defun ~/org-roam-get-linked-nodes (node tag) (defun ~/org-roam-get-linked-nodes (node tag)
"Return the nodes that NODE links to that are tagged with 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] (let ((response (org-roam-db-query [:select :distinct [dest]
:from links :from links
:inner-join tags :on (= dest node_id) :inner-join tags :on (= dest node_id)
:where (= source $s1) :where (= source $s1)
:and (= type "id") :and (= type "id")
:and (= tag $s2)] :and (= tag $s2)]
(org-roam-node-id node) tag))) node tag)))
(mapcar (lambda (id) (org-roam-populate (mapcar (lambda (id) (org-roam-populate
(org-roam-node-create :id (car id)))) (org-roam-node-create :id (car id))))
response))) 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) (defun ~/org-agenda-section-by-link (prefix tag item)
"Org super-agenda function to categorize agenda entries by linked node with TAG." "Org super-agenda function to categorize agenda entries by linked node with TAG."
(when-let* ((marker (org-super-agenda--get-marker item)) (when-let* ((marker (org-super-agenda--get-marker item))
(node (org-super-agenda--when-with-marker-buffer marker (nodes (org-super-agenda--when-with-marker-buffer marker
(org-roam-node-at-point))) (--keep (org-element-property :ID it)
(links (~/org-roam-get-linked-nodes node tag))) (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 (->> links
(mapcar #'org-roam-node-title) (mapcar #'org-roam-node-title)
(-interpose ", ") (-interpose ", ")