From 8a8845da85f920366abbc69a2718b961fc372d04 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Fri, 8 Mar 2024 18:49:55 -0500 Subject: [PATCH] Optimize Org agenda section code The tag filter can be done directly in Emacs. This probably doesn't speed things up all that much, but it does look better. --- config.org | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/config.org b/config.org index 4beb547..c4d0a45 100644 --- a/config.org +++ b/config.org @@ -2858,16 +2858,17 @@ 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." - (let* ((response (org-roam-db-query [:select :distinct [dest] - :from links - :where (= source $s1) - :and (= type "id") - :group :by dest] - (org-roam-node-id node))) - (ids (mapcar #'car response))) - (--keep (let ((node (org-roam-node-from-id it))) - (when (-contains? (org-roam-node-tags node) tag) - node)) ids))) + (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) + :group :by dest] + (org-roam-node-id node) tag))) + (mapcar (lambda (id) (org-roam-populate + (org-roam-node-create :id (car id)))) + response))) #+end_src *** Roam Buffer