How to enable magit-section-show-level-2-all in org-roam buffer?

I would like to see the article headings by default, instead of seeing
their contents in org-roam buffer. I can do this in org-roam buffer by
hitting M-2 key which seems to run magit-section-show-level-2-all
command. However, I don’t want to run this every time I open the
org-roam buffer. Is there a way to get org-roam buffer be displayed by
default this way?

I achieved the desired behavior like this:

(use-package org-roam
  ;; [...]
  :config
  ;; Collapse the backlinks buffer to its headings
  (add-to-list 'org-roam-buffer-postrender-functions
               #'magit-section-show-level-2-all)
  ;; [...]
  )
1 Like

Nice! I was only two days ago wondering how to do the same thing.

I’ve also always been running ‘toggle-truncate-lines’
upon opening the backlinks buffer. Per your model,
my config now includes this:

  :config (add-to-list 'org-roam-buffer-postrender-functions
                       #'visual-line-mode
                       #'magit-section-show-level-2-all)

and I never have to do that again. Thanks!