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).
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,
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:
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
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 (?).
Very strange. It’s the same as mine.
I can think of three posibilities.
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?
You have some function set to the org-roam-find-file-function variable that opens a new window.
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.
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.
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.