I want to close all my windows but the current one and maximize the frame so I can quickly see everything in the buffer in that one window, and then revert to my previous window setup. How would I go about doing this?
-
This link may help.– Nsukami _Commented Feb 23, 2016 at 1:51
-
3It's not real clear what you mean by "close" or "see everything in that one frame". Would (raising and) maximizing the frame you are interested in not let you see everything in that frame? The other frames would still be there, but would be hidden behind the maximized frame. This is trivial to accomplish, if it fits your need.– DrewCommented Feb 23, 2016 at 5:05
-
1Just to make sure, you're using the Emacs definition of the word frame, right? The top-level thing that gets managed by your window manager?– zckCommented Feb 23, 2016 at 5:06
-
@zck I mean the individual visible buffers I have my screen split into. I want to maximize one buffer to fill the whole screen, and then undo it so I can see all the buffers in their original configuration. I apologize if I got the vocabulary wrong, I tried to look it up and pick the best word to use– AndrewCommented Feb 23, 2016 at 18:58
-
2To clarify terminology, see: What's the difference between a buffer, a file, a window, and a frame?– Dan ♦Commented Feb 23, 2016 at 19:48
3 Answers
The different sections of text you see in your Emacs are windows. You can, for example, create a new window with C-x 2
. Yes, this terminology is confusing. It predates most GUI systems, so it's understandable if still confusing.
But once we know we're talking about windows, we can do the changes you want. To get rid of all windows except the one that point is in, run C-x 1
, mapped to delete-other-windows
.
Then, for going back to what you had before, there's a pretty useful library called winner-mode. It lets you undo and redo changes to your window configuration.
So enable winner-mode with M-x winner-mode
, and then after you call C-x 1
, you can press C-c left
to undo the change to the window configuration, setting the windows back to what they were.
If you want to permanently enable winner-mode, put (winner-mode)
in your init file.
Using winner-mode
is handy, but if you really just want to flip back and forth between one window and a multi-window configuration, here's something I've used before:
(defvar window-split-saved-config nil)
(defun window-split-toggle-one-window ()
"Make the current window fill the frame.
If there is only one window try reverting to the most recently saved
window configuration."
(interactive)
(if (and window-split-saved-config (not (window-parent)))
(set-window-configuration window-split-saved-config)
(setq window-split-saved-config (current-window-configuration))
(delete-other-windows)))
You could bind that to e.g. C-x 1
and use that same key to toggle the states.
I use the following, copied from the web. It's a quick way to leave your current window configuration. After you are done use exit-recursive-edit
to get back.
;; http://www.emacswiki.org/emacs/RecursiveEditPreservingWindowConfig
;; inspired by Erik Naggum's `recursive-edit-with-single-window'
(defmacro recursive-edit-preserving-window-config (body)
"*Return a command that enters a recursive edit after executing BODY.
Upon exiting the recursive edit (with\\[exit-recursive-edit] (exit)
or \\[abort-recursive-edit] (abort)), restore window configuration
in current frame."
`(lambda ()
"See the documentation for `recursive-edit-preserving-window-config'."
(interactive)
(save-window-excursion
,body
(recursive-edit))))
(global-set-key (kbd "C-c 0") (recursive-edit-preserving-window-config (delete-window)))
(global-set-key (kbd "C-c 1") (recursive-edit-preserving-window-config
(if (one-window-p 'ignore-minibuffer)
(error "Current window is the only window in its frame")
(delete-other-windows))))