I am new to org mode, so it might be a very simple matter, but I couldn't find/figure out it myself.

Say, I have created a few horizontal and vertical windows. Opened an org file which has some source code blocks. Then I wanted to edit one of the blocks by going into Org-Src mode using C-c ' and exiting from it using C-c '. First time I enter C-c ', all other windows in my frame closes, only the org file window stays and a new window which holds the source blocks opens. This is fine although I would prefer it to utilize some opened window. The 2nd time I use C-c ' to exit from Org-Src mode, the org src window closes, the org file window goes maximized/takes up the full frame. This is what I don't want. When I used C-c ' the 2nd time, I wanted to exit from Org-Src mode and restore my previously opened windows. I looked at manual page of Org-Src mode but the only thing I found useful was the hook function, but I don't know how I can utilize that to restore the windows after exiting from org src edit mode.

Emacs version - 27.1
Org Mode version - 9.3 (release that comes with emacs itself)
OS - Windows 10 and Linux

Question: How to restore previous window layout after quitting org-edit-src-code(C-c ') ?

  • 1
    Good question! Could you specify emacs-version and org-version ? I can't reproduce it with emacs-version = 28.0.50 (2020-10-06) and org-version = 9.4. – Firmin Martin Nov 11 '20 at 5:15
  • 1
    As this related question suggests, the relevant variable is org-src-window-setup. And if you check the documentation (C-h v), it says that Values that modify the window layout (reorganize-frame, split-window-below, split-window-right) will restore the layout after exiting the edit buffer. So maybe there is some oddity occurred in your side. Try with emacs -Q and load org-mode to see if this issue still remains. – Firmin Martin Nov 11 '20 at 21:27
  • 2
    (setq org-src-window-setup 'current-window) seems most reasonable to me. Thanks everyone, consider this as solved from my side. – shimon Nov 11 '20 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.