Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restore previous window splits in emacs [duplicate]

Tags:

split

emacs

This is an annoying issue for a long time, at least to me.

Suppose I have split the windows in certain ways. Then I found that it is difficult to view a file in a small windows, then I do C-x 1 to get a better view. But is there any way I can restore my previous window splits?

For example, when using gdb-many-windows (5 windows by default), the source code is shown in middle. I would like to view in big window (single window) then restore my original split setting (5 windows).

Hope I explain things clear.

Thanks

like image 673
Yan Zhu Avatar asked Jun 10 '13 22:06

Yan Zhu


2 Answers

The way to do it programatically in elisp is to use the current-frame-configuration function to get a list, which you can then use to restore it later.

Thus:

(setq my-window-list (current-frame-configuration))

and later:

(set-frame-configuration my-window-list)

You can easily wrap those in a function to save and load and then bind them to a key binding (possibly overriding c-x 1 so you always save on singe-window-expand).

like image 188
Wes Hardaker Avatar answered Oct 05 '22 02:10

Wes Hardaker


I often use registers to save/restore window configurations. For instance, to save it in register a do

C-xrwa

Then, to restore

C-xrja

See http://www.emacswiki.org/emacs/WindowsAndRegisters for more detail.

There are also many other, fancier tools to work with window configurations, like e2wm which is especially useful if you like to use several pre-set window configurations. See also http://www.emacswiki.org/emacs/CategoryWindows#toc4 for some other tools.

like image 31
Alex Vorobiev Avatar answered Oct 05 '22 03:10

Alex Vorobiev