Show file tags during completion, but only complete with file name

When using org-roam-node-find/insert, how can I show both file names and tags, but only perform completion on file names?

Currently, searching for e.g. ‘chemistry’ completes 40+ files that have the ‘chemistry’ tag, in addition to a node with the file name of ‘chemistry [course code].’ I would want it to show only ‘chemistry [course code]’ when I type ‘chemistry.’ However, I would still like to be able to see the ‘chemistry’ tag normally as I search.

I’m on Emacs 28.1 with Org roam commit 8667e44 (Doom Emacs).

You have to customise the variable `‘org-roam-node-display-template’ I dont know what is the correct way to refer to them but you have to define the categories through cl-defmethod then you can add those back in the variable.

The default is “${title}” – the tags is already defined so you can try “${title:*} ${tags:10}” the number determines the length after which it is truncated * means take whatever is required.

Please also look here,

If I didn’t understand your query, or you need something else let know,

1 Like

@ffter It is hard to understand what exactly you are after. Perhaps an example will help us.

My interpretation is as follows:

  • you have the following nodes:.

    (1) chemistry [course code]
    (2) nonpolar compound
    (3) nucleophile

  • All of them have a tag chemistry.

  • You want only (1) to match your search word “chemistry” and not the other two in the minibuffer on calling org-roam-node-find and -insert commands.

  • You want “chemistry” tag visible in the minibuffer for all (1)–(3).

Correct understanding?

Then you need an annotation in the minibuffer completion. Try this below, together with @akashp 's advice about org-roam-node-display-template.

(defun org-roam-node-read--annotation (node)
  (mapconcat #'identity
             (org-roam-node-tags node)

See what an outcome may look.

I have two nodes displayed in the minibuffer here. The second one being selected has tags “japonism” and “research”. The tags are not matched by my search term “japo” – only the word in the title is. That’s annotation.

Tags displayed in org-roam-node-display-template are matched (not shown in my screen shot). I think that’s what you have with the “chemistry” tag on your end.

So my suggestion is to remove the tags from display-template entirely and add them as an annotation with something like the code example above.


I sincerely apologize for the late reply. Thank you @akashp and @nobiot for the guidance; this allowed me to achieve my goal perfectly. Thank you for also linking me the user-contribute tricks page.