Capture fleeting thoughts with org-roam

13. January 2021

I frequently find myself wanting to capture a new idea or tidbit for future reference into an org-roam entry and immediately resume what I was doing, e.g. while taking notes during a meeting. org-capture and helm-org make this simple.

My workflow:

  1. Invoke org-capture (C-c c r) and select my "Roam Random" template
  2. Choose a Roam entry using org-roam-find-file
  3. Filter though the entry’s headline candidates with helm-org and finalise the capture

The capture template:

1
2
3
4
5
("r" "Roam Random" item
  (function (lambda () (my/helm-in-org-buffer (org-roam-find-file-name))))
  "- %U %?"
  :prepend t
  :kill-buffer t)

The helper functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(defun my/helm-in-org-buffer (filename &optional preselect)
  "Display and filter headlines in an org file with `helm'.
FILENAME is the org file to filter PRESELECT is the default entry"
  (interactive)
  (helm :sources (helm-org-build-sources
                  (list filename))
        :candidate-number-limit 99999
        :truncate-lines helm-org-truncate-lines
        :preselect preselect
        :buffer "*helm org in buffers*"))

(defun org-roam-find-file-name ()
  "Find and return the path to an org-roam file
with the `org-roam-find-file' interface"
  (interactive)
  (save-window-excursion (org-roam-find-file) buffer-file-name))