Show nodes of same tag in org-roam-buffer


according to the documentation, the following types of related nodes can be shown:

  • Backlinks: View (preview of) nodes that link to this node
  • Reference Links: Nodes that reference this node (see Refs)
  • Unlinked references: View nodes that contain text that match the nodes title/alias but are not linked

Obviously, there is no function that returns the nodes that share the same tag as the current node?

Is it possible, out of the box, to show nodes that have the same tag as the current node?

If not, the org-roam-buffer seems to be easily extendable. A follow up question in this direction: how to search for nodes with matching tags programmatically?


Refer to SystemCrafters’ code below referenced in this post — this post also points out a potential pitfall in code.

(defun my/org-roam-filter-by-tag (tag-name)
  (lambda (node)
    (member tag-name (org-roam-node-tags node))))

(defun my/org-roam-list-notes-by-tag (tag-name)
  (mapcar #'org-roam-node-file
           (my/org-roam-filter-by-tag tag-name)

1 Like

Thanks for your pointer!

My current work-in-progress-but-works code is:

(setq org-roam-mode-section-functions
      (list 'org-roam-backlinks-section

(defun flo/org-roam-list-notes-by-tag (tag-name)
  (seq-filter (lambda (node)
                (member tag-name (org-roam-node-tags node)))

(defun flo/org-roam-tags-section (node)
  "The tags section for NODE."
  ;; (message node)
  (when-let ((tags (org-roam-node-tags node)))
    (setq tags (cl-remove-if (lambda (tag) (string= "ATTACH" tag)) tags))
    (magit-insert-section (org-roam-tags)
      (magit-insert-heading "Tags")
      (dolist (tag tags)
        (magit-insert-section (org-roam-tags)
          (magit-insert-heading tag)
          (dolist (tagged-node (flo/org-roam-list-notes-by-tag tag))
             :source-node tagged-node
             :point 1
             ;; :properties (org-roam-backlink-properties tag
    (insert ?\n)))

Any comments appreciated!

The output is not exactly prety, the nested magit heading is not really visible as nested. Also, I wasn’t able to get a value for the point in org-roam-node-insert-section.


1 Like