Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Set a different org-roam-directory in the server #8

Open
ertwro opened this issue May 13, 2020 · 8 comments
Open

Set a different org-roam-directory in the server #8

ertwro opened this issue May 13, 2020 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@ertwro
Copy link

ertwro commented May 13, 2020

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.

@goktug97
Copy link
Member

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;

(let* ((nodes (org-roam-db-query node-query))

@ertwro
Copy link
Author

ertwro commented May 14, 2020

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.

@goktug97
Copy link
Member

goktug97 commented May 14, 2020

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

@ertwro
Copy link
Author

ertwro commented May 14, 2020

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.

@bphenriques
Copy link

👋 Is there a workaround for this?

@goktug97
Copy link
Member

👋 Is there a workaround for this?

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

@ugurbolat
Copy link

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 "./"))))
      )))

@deb75
Copy link

deb75 commented May 5, 2021

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants