[SOLVED] I want to see ONLY backlinks in side buffer, nothing else. Possible?

In my (side) buffer I don’t really want/need to see the context of the mention of the current node… I just want a list of clickable/able backlinks. That’s it - no excerpts, no transclusion, just org links that point to nodes that link to the current node.

For the life of me I can’t figure out how to do this. Is it possible?

Thank you in advance!

Have tried the user option org-roam-preview-function?

You set a function there to control what “context” you would like get for each backlink. The default is org-roam-preview-default-function.

Logically, you might like to set it to ignore function, which always returns nil. It does not work.

Try to set this function, instead:

(defun return-empty-string ()
  "")

This is probably the easiest.

Other options:

  1. Override the function org-roam-node-insert-section (either via advice or directly in the source). Not difficult and can remove extra empty space that the method above inserts.

  2. Create your own preview section to completely change the way backlink buffer works in the way you want.

Awesome, thank you @nobiot ! I used the return-empty-string function to get rid of the previews, that worked great.
Now I have a list of backlinks but they aren’t clickable/visitable.
I’ve been trying to solve that in org-roam-mode.el but I don’t know elisp well enough to really know what’s even happening.

Is there some way to make those org-roam-title’s visitable?

I can jump with RET. If you look at the wiki, I believe there is a way to get mouse click to work too (wiki is on GitHub).

Can’t jump with RET here… probably something weird about Doom (in reading threads here I see that that’s often the case). I get “There is no thing at point that could be visited”

I’ll check out the wiki… perhaps my answer lies there!

One other question… those downward-facing V symbols to the left of the node titles… are they supposed to be foldable?

Thanks so much for your help

Yes, foldable. The “V symbol” should be customizable with magit-section-visibility-indicator (I see “…” at the end of the section title on my end).

If you press number 1, 2, 3, etc. you can control the visibility. So an alternative might be to display the backlinks buffer with level 2, instead of the “empty-string” solution above. This way, you can start the side-buffer with the detail folded – I think you can use the org-roam-mode-hook and call command magit-section-show-level-2.

I do not know why you cannot jump to the linked note in the backlink buffer, though… I cannot click on it (not a problem for me), but RET just works…

Oooh nice, thank you for the help! I was able to get things working more or less the way I want.

Backlinks now show folded instead of expanded, and magit-section-show-level-2 worked like you said

I don’t remember where I found this (apologies!) but this seems to have fixed the unclickable/returnable backlink issue

(advice-add #'org-roam-fontify-like-in-org-mode :around (lambda (fn &rest args) (save-excursion (apply fn args))))

Sometimes the org-roam buffer doesn’t update when visiting a new org-roam file, so I load this function as an org-mode-hook:

(defun cb/org-roam-buffer-stuff ()
  "check if we're in an org buffer, then make sure the org-roam buffer is visible, then refresh it, collapse the V to >, turn on olivetti mode to fix weird formatting"
  (interactive)
  (if (org-roam-file-p)
      ;; if it's an org-roam buffer...
      (progn
        ;; make sure the buffer is visible
        (if (eq (org-roam-buffer--visibility) 'visible)
                ;; if the buffer is visible, great
                (with-current-buffer "*org-roam*"
                        (org-roam-buffer-refresh)
                        (olivetti-mode 1)
                        (magit-section-show-level-2))
                ;; if it's not visible, make it visible
               (org-roam-buffer-toggle)
                (with-current-buffer "*org-roam*"
                        (org-roam-buffer-refresh)
                        (olivetti-mode 1)
                        (magit-section-show-level-2))))))

then

(add-hook 'org-mode-hook 'cb/org-roam-buffer-stuff)

Thank you so much for your help!

1 Like