org-roam-server icon indicating copy to clipboard operation
org-roam-server copied to clipboard

Set a different org-roam-directory in the server

Open ertwro opened this issue 4 years ago • 8 comments

It would be cool if the server could read local variables, like org-roam does, by being launched in the browser from emacs or set a custom org-roam directory from the browser, if one has more than one org-roam-directory, for instance defined in .dir-locals.el. Yours is a wonderful addition to the nascent and expanding org-roam ecosystem. Thanks.

ertwro avatar May 13 '20 11:05 ertwro

Yours is a wonderful addition to the nascent and expanding org-roam ecosystem. Thanks.

Thank you!

The server is using org-roam functions. Doesn't changing locals affect these functions?

For example; https://github.com/org-roam/org-roam-server/blob/5c830dd937c7904d53200dcb869f68e9d3790870/org-roam-server.el#L86

goktug97 avatar May 13 '20 11:05 goktug97

Yes, org-roam-db-query connects all the *.db files. So they all become part of the same graph. While the current buffer-network view allows looking only at the nodes and edges connected to a particular node, it would be nice having the capability to only see the nodes for a particular database. Sometimes I want to show others just this particular directory's graph. Kind of like the way file viewer works.

ertwro avatar May 14 '20 05:05 ertwro

What is your way of creating and setting the second db. So I can test it while developing it.

goktug97 avatar May 14 '20 09:05 goktug97

Inside the folder that will contain the second database, I make a file called .dir-locals.el which contains the following local variable.

((nil . ((eval . (setq-local org-roam-directory (expand-file-name "./")))
	 )))

The rest is managed by org-roam, when I create new files or rebuild the database from dired or a file inside that directory.

ertwro avatar May 14 '20 13:05 ertwro

👋 Is there a workaround for this?

bphenriques avatar Aug 29 '20 08:08 bphenriques

👋 Is there a workaround for this?

You can use tags and then you can use filtering to only show one.

goktug97 avatar Aug 29 '20 08:08 goktug97

Inside the folder that will contain the second database, I make a file called .dir-locals.el which contains the following local variable.

((nil . ((eval . (setq-local org-roam-directory (expand-file-name "./")))
	 )))

The rest is managed by org-roam, when I create new files or rebuild the database from dired or a file inside that directory.

The following settings achieve what you want:

  1. create another roam.db in the local directory
  2. setq org-roam settings globally instead of setq-local
((nil . (
         (eval . (setq org-roam-directory "."))
         (eval . (setq org-roam-db-location (expand-file-name "another-roam.db" (expand-file-name "./"))))
      )))

ugurbolat avatar Apr 04 '21 15:04 ugurbolat

Hello,

I applied your settings in one local directory. It works because I noticed org-roam.db created under the directory.

Then, I wonder what becomes the init.el settings :

(use-package org-roam
  :ensure t
  :hook
  (after-init . org-roam-mode)
  :custom
  (org-roam-db-location "c:/Users/xxx/org-roam/org-roam.db")
  (org-roam-directory "d:/xxx/Documents/org-roam/")

Thanks to your post, these initial settings seem no more relevant. Should I keep these ? so that they make org-roam point to the default settings ?

Also, because your post allows to have directory based settings for org-roam. Is there an interactive function which would let you choose the directory you want org-roam to point to ? Currently, as far as I understood the only way is to open a file in that directory.

Regards

deb75 avatar May 05 '21 09:05 deb75