Imagine I have a frame containing some number of windows—sometimes only one, sometimes split in various ways.

Now imagine that one of the displayed windows contains an org-mode buffer. What I want is:

  1. When I invoke org-edit-src-code, I want to
    • save the current configuration of the window,
    • delete all the other windows on that frame, and
    • display only the source-editing window in that frame.
  2. When I invoke org-edit-src-exit to return to the org-mode buffer, I want to restore that frame's original window configuration. (Obviously, if some of the other buffers have been killed in the interim, those windows will have to display something else.)

The display-buffer and window-quit don't seem to offer such a capability, but maybe I'm missing it.

I'm imagining implementing it using a custom "display action function" that would stash the window configuration (from current-window-configuration) in a window parameter and with a custom quit-window-hook that would check for that window parameter.

  1. Does something like this already exist?
  2. Does this seem like a stupid thing to even want?
  3. Does such a sketch of a plan seem like a reasonable approach?
  • 1
    – Drew
    Dec 7, 2021 at 22:56
  • Please narrow your question. One question per post.
    – Drew
    Dec 7, 2021 at 23:03
  • 1
    From the looks of the code, org-edit-src-exit already tries to restore a window configuration. Maybe you should look into why that's not already the config you want, and see if you can arrange that it is.
    – phils
    Dec 7, 2021 at 23:52

1 Answer 1


This should get you started. One of the easiest ways to save an restore a window config is to use a register. See the Emacs manual, node Configuration Registers.

That explains how to do this interactively. You can use the code that accomplishes it in your own Elisp code, to do whatever similar you like.

Here is that entire Elisp-manual node:

You can save the window configuration of the selected frame in a register, or even the configuration of all windows in all frames, and restore the configuration later. See Windows, for information about window configurations.

  • C-x r w R

    Save the state of the selected frame’s windows in register R (window-configuration-to-register).

  • C-x r f R

    Save the state of all frames, including all their windows, in register R (frameset-to-register).

Use C-x r j R to restore a window or frame configuration. This is the same command used to restore a cursor position. When you restore a frame configuration, any existing frames not included in the configuration become invisible. If you wish to delete these frames instead, use C-u C-x r j R.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.