I’ve created 2 separate org-roam databases by using .dir-locals.el as described in the manual.
Everything works smoothly regarding org-roam-node-find, org-roam-node-insert, etc. and org-roam-current-directory and org-roam-buffer-current-directory return the correct directory.
However, upon running org-roam-buffer-display-dedicated on a node in org-roam directory 2, org-roam-current-directory and org-roam-buffer-current-directory are set to org-roam directory 1 and nothing is displayed properly.
If my cursor is in the org-roam buffer and I manually set org-roam-buffer-current-directory to org-roam directory 2 and refresh the buffer, it displays everything correctly. However, it only changes this for the specific node I’d set the variable for.
TL;DR In a 2nd org-roam directory, org-roam-buffer-current-directory is set to the wrong directory upon running org-roam-buffer-display-dedicated
Why does this happen? Does anyone have any solutions for this?
Emacs applies .dir-locals.el when it visits your file (from the manual, quoted below)
Whenever Emacs visits any file in that directory or any of its subdirectories, it will apply the directory-local variables specified in .dir-locals.el, as though they had been defined as file-local variables for that file (see Local Variables in Files).
When you call org-roam-buffer-display-dedicated, Emacs creates a new buffer. As it does not visit a file, Emacs does not apply .dir-locals.el to it and instead uses the default value of org-roam-directory. See the lines of code below.
A solution? I suggest an easy way is to add a let binding after line 279 and pass the current local value of org-roams-directory. I am on the iPhone and about to sleep. But does this make sense?
This should be changed to something like this below:
(let ((buffer (get-buffer-create (org-roam-buffer--dedicated-name node)))
(dir org-roam-directory)) ; this should take the current local value. And change the following form in line 282 to use the variable `dir`.