# Preview link target?

**URL:** <https://org-roam.discourse.group/t/preview-link-target/1452>\
**Category:** How To\
**Created:** [April 6, 2021, 7:29pm UTC](https://org-roam.discourse.group/t/preview-link-target/1452 "2021-04-06T19:29:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 7, 2021, 4:49pm UTC](https://org-roam.discourse.group/t/preview-link-target/1452/2 "2021-04-07T16:49:49Z")

</div>

> [@midas](#):
>
> When working in a note, is it possible to preview the link-at-point? I know there are ways to open a separate buffer and jump to link-target. I was thinking of a more dynamic option. For example, the backlink buffer could be a place to display a few lines of the link-target (I imagine mini-buffer is too small)

I believe the answer is “Yes”, but it would be more for custom scripting. I do not know of any package that does it for you.

It’s probably useful to clarify what you are really going for with a simple prototype. See the GIF animation below (code follows, so you can try it yourself).

![2021-04-07T181500_link-preview-2](https://global.discourse-cdn.com/free1/uploads/orgroam/original/1X/6fc73b20166fce103ba95222346525d915c2b768.gif)

The script is very simple and does the following:

1. Temporarily set `display-buffer-alist` so that a target buffer opens in a side-window at the bottom of a screen with a specified height of 25% of the screen
2. Use the standard `org-open-at-point` function to open the link at point (depending on your Org config it might behave differently on your end)

You can see that I am trying to “preview” the ID link. When I call `my/link-preview` command, a new buffer opens at the bottom and my cursor (point) moves into it – because of this, my `*org-roam*` buffer refreshes. It’s a V2 backlink buffer but that is not relevant now.

This is probably missing some elements you are really going for, but I think it’s not too far off the mark. You probably want a couple of more elements:

1. The cursor to stay in the note, so that you can keep working in your note
2. It should be possible to toggle the “preview buffer” easily with a single function key for instance (e.g. F9)
3. Display the preview buffer on the side, next to the backlink buffer (I prefer a side-buffer at the bottom this way)

These would be rather simple modifications to achieve.

> [@midas](#):
>
> Another option is to show a preview when mouse hovers over the link

This would be more involved. I am not interested in the mouse hover in Emacs in general, but as an example, @cool_ran has [done something](https://org-roam.discourse.group/t/prototype-org-marginalia-write-margin-notes-with-org-mode/1080/3) that you could look to apply to this purpose with `postframe`.

> [@midas](#):
>
> a preview when looking at list of org-roam files would also be useful. One use-case is when executing org-roam-find-file.

This would be something you might like to consider using `consult` package. For example, see [the video demo](https://org-roam.discourse.group/t/using-consult-ripgrep-with-org-roam-for-searching-notes/1226) @emacsomancer has put together for `consult-ripgrep` – if you run it for `org-roam-directory`, I think you get something pretty close.

[New UI possibilities](https://org-roam.discourse.group/t/find-node-ui-possibilities-for-v2/1422) that @bruce is considering for V2 might be going in this direction.

> [@midas](#):
>
> Another more interesting use-case is when using dired buffer

As a similar attempt for Dired, I have done [this](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018/5), which might be close to what you are going for. There might be a better way with `consult`; it might converge with the V2 UI possibilities I mention above.

For all these options, my sense is that the first option that I did with a prototype is the easiest and most practical (for me). I might explorer it a bit more (I feel it rather useful for myself).

EDIT: Forgot to add the prototype script…

```auto
#+begin_src emacs-lisp
  (defun my/link-preview ()
    (interactive)
    (let ((display-buffer-alist
           '(;; Bottom side window
             (".*"
              (display-buffer-in-side-window)
              (window-height . 0.25)
              (side . bottom)
              (slot . 0)))))
      (org-open-at-point)))
#+end_src

```

---

_[View the full topic](https://org-roam.discourse.group/t/preview-link-target/1452)._
