7

When I follow from one Org file to another via a link, the new file appears in alternative window if there is one. Is there a way to follow links staying in the same window?

For example, I use a frame with two horizontally split windows. Left is for code, right is for docs in Org format. If I follow a link in the right window, the new Org file is opened on the left side, and I do not see the buffer with a code anymore.

2 Answers 2

10

The behaviour for opening files is set in org-link-frame-setup.

By default, the behaviour for opening files is file-find-other-window.

The following two alternative commands will change that so that find-file is executed instead of find-file-other-window:

(setf (cdr (assoc 'file org-link-frame-setup)) 'find-file) 
(setf (cdr (rassoc 'find-file-other-window org-link-frame-setup)) 'find-file) 
1
  • 1
    Maybe it would be good to add that if you want the default behavior sometimes, you can use C-x 4 C-o or C-x 5 C-o with the cursor on a link, respectively. Commented Jul 1, 2023 at 14:35
7

This works for me:

 (setq org-link-frame-setup '((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))) 

The above code was automatically generated by Emacs when I customized the variable. I merely recast it using setq.

4
  • please explain/reason a little your response Commented Jan 14, 2021 at 16:32
  • enough, add it to response and it's good. Commented Jan 14, 2021 at 17:02
  • 2
    In the end I also changed it via customization, but I decided to leave it where it is and do not use setq for it. Commented Jan 15, 2021 at 12:06
  • There is no problem with that. I use setq because it helps me to better organize my configurations together. Commented Jan 15, 2021 at 16:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.