Tristan401 · 2022-09-13 23:16
Howdy. Apologies if this is a duplicate, I searched but couldn't seem to find anything. I'm in the middle of migrating my PKM system into org-roam. One issue I'm having is org-roam keeps opening every note in org-roam-directory. I close them, do some work, and suddenly they're back. I kill them, close emacs, reopen it, and BAM they're already there without me even doing anything.
My current org config:
```
;; -------------------------------------
;; ORG-MODE
;; --------
;; Custom startup stuff
(defun mmacs/org-mode-setup ()
(org-indent-mode)
(auto-fill-mode 0)
(visual-line-mode 1))
;;
;; org-mode
(use-package org
:hook (org-mode . mmacs/org-mode-setup)
:config
(setq org-ellipsis " ▾"
org-hide-leading-stars t
org-startup-folded t
org-return-follows-link t))
;; -------------------------------------
;; -------------------------------------
;; ORG-AGENDA
;; ----------
(setq org-agenda-files '("REDACTED/BECAUSE/REASONS")
org-agenda-start-with-log-mode t
org-log-done 'time
org-log-into-drawer t)
;; -------------------------------------
;; -------------------------------------
;; ORG-ROAM
;; --------
(use-package org-roam
:ensure t
:init
(setq org-roam-v2-ack t)
:custom
(org-roam-directory "/REDACTED/BECAUSE/REASONS")
(org-roam-complete-everywhere t)
(org-roam-capture-templates
'(("d" "default" plain
"%?"
;; sick and tired of these stupid names, just name it what I tell you!
:if-new (file+head "${title}.org" "#+title: ${title}\n#+date: %U\n")
:unnarrowed t)))
:config
(org-roam-setup)
(org-roam-db-autosync-mode))
;; -------------------------------------
```
eis3nheim · 2022-09-14 00:33
The reason for such action is your settings for Org-agenda-files.
You shouldn't specify a directory.
That directory will be opened everytime you open your Emacs.
Tristan401 · 2022-09-14 01:06
It worked! Thanks a ton!
edit: well, it worked, but now my TODOs will be missing. Any way to keep the directory but not open the files? It needs to be a directory, there's no way I could do TODOs in just one file.
ahopefullycuterrobot · 2022-09-14 01:50
There's a hack from [System Crafters](https://systemcrafters.net/build-a-second-brain-in-emacs/5-org-roam-hacks/).
```
;; The buffer you put this code in must have lexical-binding set to t!
;; See the final configuration at the end for more details.
(defun my/org-roam-filter-by-tag (tag-name)
(lambda (node)
(member tag-name (org-roam-node-tags node))))
(defun my/org-roam-list-notes-by-tag (tag-name)
(mapcar #'org-roam-node-file
(seq-filter
(my/org-roam-filter-by-tag tag-name)
(org-roam-node-list))))
(defun my/org-roam-refresh-agenda-list ()
(interactive)
(setq org-agenda-files (my/org-roam-list-notes-by-tag "Project")))
;; Build the agenda list the first time for the session
(my/org-roam-refresh-agenda-list)
```
Basic idea is that it will find all roam nodes with a specific tag, then open those all as your agenda.
Tristan401 · 2022-09-14 02:04
I may just have to rethink how I do TODOs then. This doesn't seem viable for hundreds or thousands of notes, as it's still opening every file, and every file in my knowledgebase is potentially a TODO file.
JustinSilverman · 2022-09-14 02:28
This has kept me from org-roam interested if you find a solution
Tristan401 · 2022-09-14 03:16
What do you use instead?
na85 · 2022-09-14 06:09
I don't use org-roam but I don't see how it can create its knowledge graph without opening the files to read their contents.
I believe it's intended for the use case where a person leaves an emacs daemon running in the background at all times.
loskutak-the-ptak · 2022-09-14 06:20
I use this hack:
((org-agenda-files (append org-agenda-files
(with-temp-buffer
(call-process "grep" nil t nil "-lRE" "--include" "\*.org" "TODO|NEXT|WAITING|TODAY" "/path/to/my/roam/directory")
(split-string (buffer-string) "\n" t)))))
(sorry, the indentation is somehow broken)
This greps the roam directory for org files containing one of the todo keywords I want and only adds these to org-agenda-files. I do this once during init (so new todos wont show), because I don't use roam that much, but I think you can do this dynamically with something like:
(let ((org-agenda-files ...))
(org-agenda))
Anyway, grepping for todo keywords is much much faster, than loading all the roam org files and fully parsing them by org-mode.
[deleted] · 2022-09-17 19:36
[removed]