In Emacs, can we maximize current active window, and then restore it back in multiple window environment?
Asked Answered
S

5

8

I like to open multiple window, each with its own file opened. Sometimes, I want to maximize the one I edited to occupy whole screen, and then to restore it back to its previous size and position..

Is there a way?

According to the emacs menu, I can only figure out enlarge-window, shrink-window.. thats it..

Slick answered 19/1, 2011 at 6:54 Comment(0)
H
12

More or less - try using winner-mode. It will remember the last few (ca 200) window configurations, and will let you walk through them with a simple (C-c (right|left)) keystroke. And it's quite easy to turn on, since it's built in:

(when (fboundp 'winner-mode)
  (winner-mode 1))

Combine it with windmove and moving between your windows will be even more awesome.

Hallowmas answered 19/1, 2011 at 7:47 Comment(2)
that screwed up my brain ^_^ I'll read your link first! thanksSlick
maxelosts solution is also very handy, that's what I use when I know I need to return to a certain window configuration, but most of the time, I don't know and get supriced when my window is changed. In those cases, winner-mode is awesome.Hallowmas
H
6

Use the command window-configuration-to-register: M-x window-configuration-to-register, press the Enter key, then some register (character), e.g. a. To maximize current window, use C-x 1. When you want to restore, type C-x r j a.

Hilariahilario answered 19/1, 2011 at 7:49 Comment(3)
window-configuration-to-register is handy, but you should also try M-x winner-mode maxelost. It's the same, but doesn't require you to store the configuration before it's lost.Hallowmas
@monotux: yes, it does seem handy.Hilariahilario
owh, I got it. So let say we open one file, on main window. When I split it into two window horizontally, it means that the previous window configuration is saved, and we can get it back using C-c left. Okay, this is awesome!!!Slick
L
1

Workaround.

  1. ESC ESC ESC maximizes the buffer with active cursor.
  2. M-x ` to navigate between other buffers.
Leggat answered 20/4, 2019 at 15:0 Comment(0)
T
0

Have exactly what is asked for, no more no less, in my setup since ages:

(setq window-zoom-config nil)
(defun window-zoom()
    "Zoom current window so it takes the whole frame.
The next time the function is called, the layout before
zoom is restored."
    (interactive)
    (if (eq nil window-zoom-config)
            (progn
                (setq window-zoom-config (current-window-configuration))
                (delete-other-windows)
                (message "Saved window configuration"))
        (set-window-configuration window-zoom-config)
        (setq window-zoom-config nil)
        (message "Restored window configuration")))

Just bind your favorite key to window-zoom and off you go. You can even split again and create your own layout while in "zoom" for your temporary work, still the previous layout is restored when called again.

Thrips answered 19/3 at 1:49 Comment(0)
N
0

I always use winner-mode for this, but it's worth noting these options as well:

  1. In GUI or terminal frames (since Emacs 27.1):

    C-xt2 -- tab-new

    This opens a new tab displaying only the buffer which had been current in your previous window configuration. You can flip back and forth between the tabs (each of which has an independent window configuration), and delete the current tab with C-xt0 when you've finished with it. (n.b. You can (setq tab-bar-show 1) to hide the tab bar when it has only a single tab.)

  2. In terminal frames only:

    C-x52 -- make-frame-command

    While in GUI frames this command would create a whole new frame (GUI window), in a terminal the new frame is displayed in place of the previous frame, which makes this very much like the tab-bar method described above (just without any tabs). You can cycle frames with C-x5o and delete the current frame with C-x50 once you've finished with it.

Nummary answered 19/3 at 2:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.