11

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 _ Feb 23 '16 at 1:51
  • 3
    It'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. – Drew Feb 23 '16 at 5:05
  • 1
    Just 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? – zck Feb 23 '16 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 – Andrew Feb 23 '16 at 18:58
  • 2
    To clarify terminology, see: What's the difference between a buffer, a file, a window, and a frame? – Dan Feb 23 '16 at 19:48
14

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.

7

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.

1

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))))

Your Answer

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

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