# Clicking backlinks in side buffer behavior

**URL:** <https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906>\
**Category:** Requests\
**Created:** [December 20, 2022, 2:42pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906 "2022-12-20T14:42:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alpha\_one](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@alpha\_one](https://org-roam.discourse.group/u/alpha_one)\
**Post date:** [December 20, 2022, 2:42pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/1 "2022-12-20T14:42:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [December 22, 2022, 12:23pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/2 "2022-12-22T12:23:26Z")

</div>

Does [this in the wiki](https://github.com/org-roam/org-roam/wiki/Hitchhiker's-Rough-Guide-to-Org-roam-V2#navigation-in-backlink-buffer) work for you? If not, you can try something along the line of this:

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

```

---

<div class="post-metadata">

**Author:** ![alpha\_one](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@alpha\_one](https://org-roam.discourse.group/u/alpha_one)\
**Post date:** [December 22, 2022, 5:03pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/3 "2022-12-22T17:03:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [December 22, 2022, 5:17pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/4 "2022-12-22T17:17:14Z")

</div>

> [@alpha\_one](#):
>
> but it directs to the target in the side buffer, not the main window.

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…

```auto
(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)

```

---

<div class="post-metadata">

**Author:** ![alpha\_one](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@alpha\_one](https://org-roam.discourse.group/u/alpha_one)\
**Post date:** [December 29, 2022, 7:33pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/5 "2022-12-29T19:33:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iamkarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/iamkarlson/32/1336_2.png) [@iamkarlson](https://org-roam.discourse.group/u/iamkarlson)\
**Post date:** [June 6, 2023, 7:54pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/6 "2023-06-06T19:54:36Z")

</div>

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:

```auto
(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.

---

<div class="post-metadata">

**Author:** ![iamkarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/iamkarlson/32/1336_2.png) [@iamkarlson](https://org-roam.discourse.group/u/iamkarlson)\
**Post date:** [June 6, 2023, 8:49pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/7 "2023-06-06T20:49:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [June 6, 2023, 9:15pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/8 "2023-06-06T21:15:44Z")

</div>

> [@iamkarlson](#):
>
> 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

```auto
  (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](https://github.com/org-roam/org-roam/blob/main/org-roam-mode.el#L433-L435).

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

---

<div class="post-metadata">

**Author:** ![iamkarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/iamkarlson/32/1336_2.png) [@iamkarlson](https://org-roam.discourse.group/u/iamkarlson)\
**Post date:** [June 7, 2023, 6:48pm UTC](https://org-roam.discourse.group/t/clicking-backlinks-in-side-buffer-behavior/2906/9 "2023-06-07T18:48:46Z")

</div>

You are right, sorry!
