Clicking backlinks in side buffer behavior

When I click backlinks in the side buffer, it opens the link in the side buffer rather than in the main buffer window to the left. I can navigate as intended using the C-u RET on a backlink in the side buffer, but how do I do this via the mouse?

Using org-roam-ui mode is a lot easier with the mouse to navigate around.

Thanks!

Does this in the wiki work for you? If not, you can try something along the line of this:

(define-key org-roam-mode-map [mouse-1] #'org-roam-preview-visit)

Unfortunately no. I tried the wiki version earlier and tried the new one; in both cases the link is followed successfully but it directs to the target in the side buffer, not the main window. This causes me to have to collapse the windows C-x 1 then open up a new side buffer, which is not great

You can influence this in your configuration but that’s probably too complicated for me to explain – mine actually opens a link in the main buffer.

You might like to try the following and let us know how you go. It works on my end.

It may not work if you are using Doom, which has its own way of dealing with pop-up windows…

(defun my/org-roam-preview-other-window ()
  (interactive)
  (org-roam-preview-visit 
   (org-roam-buffer-file-at-point 'assert)
   (oref (magit-current-section) point)
   :other-window))

(define-key org-roam-mode-map [mouse-1] #'my/org-roam-preview-other-window)
1 Like

Thank you! I can confirm the snippet above is successful. Perhaps a good candidate for inclusion in the documentation?

Surprisingly it has not straightforward behavior. If I copy @nobiot’s code as is - it doesn’t work. However, adding a message to the function fix it:

(defun my/org-roam-preview-other-window ()
  (interactive)
   (oref (magit-current-section) point)
  (org-roam-preview-visit
   (org-roam-buffer-file-at-point 'assert)
   (message "test message")
   :other-window))

(define-key org-roam-mode-map [mouse-1] #'my/org-roam-preview-other-window)

I don’t understand how it works - but it currently has a correct navigation by visiting a window on the left, while org-roam’s buffer is on the right.

Alright, it turns out that this is the function signature was wrong. Instead of my debug message I had to pass POINT in the file where jump to. I figured it by opening describe-function for org-roam-preview-visit. Perhaps there’s some initial idea how to find a POINT where you should jump to?

I am not 100% sure what you are asking, but if you go back to my original code

  (org-roam-preview-visit 
   (org-roam-buffer-file-at-point 'assert)
   (oref (magit-current-section) point)
   :other-window))

(oref (magit-current-section) point) gets the POINT to jump to. This part that calls org-roam-preview-visit is essentially a copy of this part of the source.

My original code still works on my end; I just tested it.

You are right, sorry!

1 Like