Help Implementing the "Opening Internal Links in The Same Window/Frame" Work-around Fix

Hi Org-Roam Discourse,

I need some help with implementing a work around to an org-roam issue with opening back-links. Currently, backlinks open up in a split window. This is a known issue that is tracked on github repo, and is talked about on this forum ( Opening Internal Links in The Same Window/Frame).

The workaround solution given on github for this issue is: emacs - How to let Org-mode open a link like [[file://]] in current window instead of default in other window? - Stack Overflow :

(defun org-force-open-current-window ()
(let ((org-link-frame-setup (quote
((vm . vm-visit-folder)
(vm-imap . vm-visit-imap-folder)
(gnus . gnus)
(file . find-file)
(wl . wl)))
;; Depending on universal argument try opening link
(defun org-open-maybe (&optional arg)
(interactive “P”)
(if arg
;; Redefine file opening without clobbering universal argumnet
(define-key org-mode-map “\C-c\C-o” 'org-open-maybe)

I’m struggling to get this to work, given I’m new to emacs. My first problem, is that when I rebind C-c C-o to any command (e.g. i rebound it to so C-c C-o opens eshell), the rebind works when I go C-c C-o, but doesn’t get triggered when I just press the backlinks normally. Why is this? Is this because I use doom? If so how do I re-bind clicking on the backlinks to this org-force-open-current-window function?

Many thanks,
Hope this was the appropriate place to ask,


Hi @lex,

Do you just want to move from Note A to Note B in Org-roam without opening a new split window? Like I am doing in this animation below?

By the way, I have kept the backlink side pane (window in Emacs jargon) open to prove that I was in Org-roam. If I have it closed, Emacs won’t open it. If it does, I think that’s Doom config.

If this is correct understanding, it’s much simpler. I think I have helped someone on Slack before.

You can just customize org-link-frame-setup.
You can use M-x customize-variable and enter “org-link-frame-setup”.
Change (file . find-file-other-window) to (file . find-file)

Your default (even in Doom) probably looks like this:

        ((vm . vm-visit-folder-other-frame)   
         (vm-imap . vm-visit-imap-folder-other-frame) 
         (gnus . org-gnus-no-new-news)  
         (file . find-file-other-window) ;;<- Change this to (file . find-file)                                            
         (wl . wl-other-frame))

The splitting of the window only occurs when I take a link from the backlink side pane (e.g. in your example, if I were to take the note B side link to note A).

If I take a normal link in the body of the note, e.g. just clicking on Note B link from within body of Note A, I don’t actually have any problems with the windows splitting.

I just closed my PC, but jumping from the backlink buffer does not open a new split window on my machine… Is that something Doom does? I’ll come back tomorrow my time to make sure what I’m saying is correct

On the Github Repo, they say it is a problem with org-mode org-open-at-point function I think. I have the same problem as identified here [Question] How to always open backlinks in full windows · Issue #920 · org-roam/org-roam · GitHub

I don’t think it is doom specific, they seemed to think it is org-mode specific problem.

Interesting that backlinks don’t split the window on your device… i wonder what is different :\

I’d appreciate if you can check the value set for org-link-frame-setup in the mean tjme

((vm . vm-visit-folder-other-frame)
(vm-imap . vm-visit-imap-folder-other-frame)
(gnus . org-gnus-no-new-news)
(file . find-file)
(wl . wl-other-frame))

@lex thank you.

I looked. On my machine, it behaves as you want it to:

Looking at the source code, this behaviour is achieved through org-roam-open-at-point function added to org-open-at-point-functions hook (variable). It is done locally, so if you wish to inspect it, you would need to put your cursor in the org-roam backlinks buffer.

It was “fixed” 7 months ago. …So if anything, I suspect Doom might do something for itself to override it (?).

My org-open-at-point-functions variable is set as:


edit: wasn’t inspecting locally (d’oh)

Is it supposed to also contain org-roam-open-at-point function in there?

Also want to say thanks so much for helping me out with all this, I greatly appreciate it!

Oh wait, I’m idiot, wasn’t inspecting it locally. It is this:


Very strange. It’s the same as mine.
I can think of three posibilities.

  1. All my demos have been on terminal, so I am not using a mouse to click. Instead, I used C-c C-o and simply pressing the Enter key. The mouse click might have a different function bound to it. Try Enter key or C-c C-o?

  2. You have some function set to the org-roam-find-file-function variable that opens a new window.

  3. find-file in your system is advised – that is overridden to do something else. You should be able to see it via C-h f RET find-file. If there is an advice function to it, the help documentation will tell you that.

I inspected the program sequence in runtime, and mine went like this:
org-roam-open-at-point -> org-roam-buffer--find-file -> org-roam--find-file

In the end, it will call a function either set to org-roam-find-file-function, or use the stock standard find-file (see the screen below). You may have some custom function set to this variable.

Alternatively, you can add this to your init file:

(setf (cdr (rassoc 'find-file-other-window org-link-frame-setup)) 'find-file)

This code looks for find-file-other-window in the org-link-frame-setup variable and replaces it with find-file.

Thank you!

Does this solution work when the variable does not contain find-file-other-window?

No, the code finds the associated value of find-file-other in theorg-link-frame-setup alist. It then changes the cdr of that cons to find-file.

The window also splits if I use C-c C-o over the backlink too, its not just if I click with mouse. @nobiot

I’ll try and implement your fix tomorrow @danderzei
I need to figure out how to insert it into the doom init.el, I’ll need to read the documentation, because it must be more than just copying and pasting it in at the bottom, since this causes an error.

Can’t help you with Doom. I use Vanilla Emacs.

I have a feeling that I somehow made it to work with Doom. I installed it to see it myself.

Doom seems to put its own set of customizing (with +roam and standard). See below what I have done.

Initially the normal Org link errored with some doom-jump something missing. So I don’t fully get it.

If you really need full understanding, I would suggest you try the Doom related forum. I won’t be able to analyse how Doom really works (it is really frustrating to work with Doom; I don’t think that is its fault; it seems to take a lot of getting use to. Personally, I didn’t feel that I could tame it to my liking any more – I used to use it).

  (setq +org-roam-open-buffer-on-find-file nil)  ;; with +roam, it defaults to t                                
  (setq org-roam-buffer-window-parameters nil)  ;; with +roam, it has some value                 
  (setq org-open-at-point-functions '(org-roam-open-id-at-point)) ;; Looks like Doom puts something related to `jump` something, which I don't fully understand

I added
(after! org
(setf (alist-get 'file org-link-frame-setup) 'find-file))

to my config.el file @danderzei. Not sure if this is the same code as the one you wrote for me, i think it is. It didn’t make a difference though.

Something strange about the behaviour, something I should have mentioned, is that the first backlink I click on doesn’t split the window in half. It is only from then on that clicking the back link splits the window.

I’ll have a look at this nobiot, thanks. I did just try throwing this in my config.el and see if it would make any difference, and it didn’t work, but I’ll have a little more of a look at it

Will try asking some doom users who also use org-roam, see if they found a fix

Try toggling the backlinks buffer via org-roam or org-roam-buffer-toggle-display. There is certainly something there. See this GIF I have also taken. The first navigating on the link in the backlink buffer works as we want; the second one splits the window. This behaviour seems to disappear when you have toggle the backlink buffer.

There is something going on behind the scene I cannot tell what. It’s an uncharted sea for me; very hard to navigate without an experienced guide in Doom.