Can't open node if another node's name starts with the same string

I’m using Emacs version 26.3, and org-roam version 2.0.0 on Linux.

I ran across a problem on my newly started org-roam setup. So to try to isolate the issue, I restarted with a new empty notes directory, but I still had the exact same issue, and this is what I found:

  1. I can open a note called “foo” as long as there are no other nodes with names starting with “foo”.
  2. If I do have two nodes, one called “foo” and the other “foo bar”, then I can no longer open “foo” with org-roam-node-find - when I try, I get a new empty CAPTURE buffer with the name “foo” - I get a duplicate.

Anybody have any ideas how to solve this?

This is my setup:

(ido-mode t)
(use-package org-roam
:ensure t
(setq org-roam-v2-ack t
org-roam-db-update-method 'immediate)
(org-roam-directory “~/devel/RoamNotes”)
;(org-roam-completion-everywhere t)
:bind ((“C-c n l” . org-roam-buffer-toggle)
(“C-c n f” . org-roam-node-find)
(“C-c n i” . org-roam-node-insert)
:map org-mode-map
(“C-M-i” . completion-at-point))

For ido-mode, try completing the selection with TAB key. In your example, the note named “foo” is probably not “foo” but “foo ” (with many spaces). To avoid matching with “foo bar”, you might need to put more than one space and then TAB complete.

To avoid this many spaces, you can change the customizing variable org-roam-completion- format-template (something like this; let me come back to it when I have a PC in front of me; there should be a couple of recent posts about it). The key is to replace the default “{title:*}” with something like “{title}”, removing the “*” width specifier.

1 Like

That sounds exactly right, thank you! I have noticed that when I auto complete names with tab, I do get a boatload of spaces at the end, but I thought that was just a display glitch. I appreciate your help in resolving this…

Try something like this:

(setq org-roam-node-display-template "${title} ${tag}")

The key is to remove the default “width specifier” “:” and “*” from the variable. If you don’t use tags, I would also suggest remove ${tag} and a space before it completely – the space also is inserted to IDO completion as a space.

This whole thing is mainly designed for vertical completion UI (I believe all but the built-in completion, IDO, and Icomplete) to align candidates to columns. For the horizontal completion UI like IDO, it works against intuition.

1 Like

Thank you, that solved the problem! Much appreciated, now I can get on with building my second brain (turns out my first one is lacking)!

1 Like

You can just type control-return after entering the substring for the node name
This result I found in

For common completion frameworks (e.g. ivy, vertico), <enter> is used to select candidates.

For vertico, your case requires C-<return> (vertico-exit-input).