1

When I do C-c C-o on an org link it opens the org file in a new window. This is fine, but sometimes I'd prefer to open org files within the current window, creating a new key binding for the matter (for example "C-c <C-return>").

I've tried to adapt some code I found on emacs.stackexchange, namely :

How to force Org-mode to open a link in another frame?

(defun zin/org-open-other-frame () "Jump to bookmark in another frame. See `bookmark-jump' for more." (interactive) (let ((org-link-frame-setup (acons 'file 'find-file-other-frame org-link-frame-setup))) (org-open-at-point))) 

and Open org link in the same window

(setf (cdr (assoc 'file org-link-frame-setup)) 'find-file) 

But my understanding of Elisp is so poor that I didn't manage to do it...

2 Answers 2

2

Adding this to your init will allow you to open a link in the current window through C-o:

 (defun mda/org-open-current-window () "Opens file in current window." (interactive) (let ((org-link-frame-setup (cons (cons 'file 'find-file) org-link-frame-setup))) (org-open-at-point))) (define-key global-map (kbd "C-o") #'mda/org-open-current-window) 
1

With Emacs 28.1 and above, you may use C-x 4 1 C-c C-o.

The key prefix C-x 4 1 will display the buffer opened by the next command in the same window.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.