April 21, 2022

Searching Org-roam files

Org-roam is A plain-text personal knowledge management system” using Emacs and Org-mode and I put nearly all my notes in there. While it’s easy to find notes in org-roam based on filename, there’s no obvious way to search the contents of notes. Weird, right?

I could use the default projectile search, but my org-roam files live within my main ~/org directory, so the results are littered with all my other org documents. I’d prefer to only search in ~/org/roam

I use a simple lisp function to help with this. It uses consult-ripgrep:

    (defun jab/search-roam ()
     "Run consult-ripgrep on the org roam directory"
     (consult-ripgrep org-roam-directory nil))

I added a keybinding for it to my other org-roam bindings:

     "C-c n f" 'org-roam-node-find
     "s-u" 'org-roam-node-find
     "C-c n i" 'org-roam-node-insert
     "C-c n t" 'org-roam-dailies-goto-today
     "C-c n d" 'org-roam-dailies-capture-today
     "C-c n c" 'org-roam-capture
     "C-c n s" 'jab/search-roam               ;; <-- my new keybinding
     "C-c n l" 'org-roam-buffer-toggle)

Now, with a quick C-s n s I can search my org-roam files using the blazingly fast ripgrep .

If there’s a better way to do this, I’m all ears.

Emacs Orgmode

Previous post
The West Wing Productivity System The last time I rewatched “The West Wing” I was once again impressed by how good people were at their jobs. How productive everyone was. I wondered
Next post
I need a new film scanner My Epson V750 Pro, purchased in 2009, has scanned thousands of rolls of film, slides, and prints. After making strange grinding noises recently, it