Replacing zoom-window with winner-mode to Temporarily Change Window Splits in Emacs
On Reddit, there was a recent thread called “Your dependency on external packages reduce with experience”.
I have been using zoom-window
in the past to temporarily “unsplit” buffers. So this:
┌───┐╔════════════╗┌─────┐
│ │║ ║│ │
│ A │║ C ║│ B │
│ │║ ║│ │
│ │║ focus, ║│ │
│ │║ center ║│ │
└───┘╚════════════╝└─────┘
Turns into this:
╔════════════════════════╗
║ ║
║ C ║
║ ║
║ focus, ║
║ center ║
╚════════════════════════╝
The clou with “zooming” is that this is just a temporary override. In Xcode, you have a similar functionality to collapse split editors temporarily. That’s useful to focus on code, esp. long lines, or when the display is small.
There’s a built-in Emacs mode, winner-mode
, that replaced this functionality for me. winner-mode
allows undoing and redoing changes to the window layout.
This effectively is a functionally equivalent approach: instead of using a package that unsplits temporarily, I can just use the regular shortcut to unsplit windows, and then undo the change later.
Using this more general package enables different uses. If I split a window three times, I can undo the last split and keep two. It’s more flexible in that regard. It also saves me from accidental changes to carefully crafted layouts.
So in the spirit of the Reddit discussion, I noticed that I, too, learned to use built-in functionality instead of relying on an external package that I thought I needed.
Don’t get me wrong: zoom-window
is great and works reliably! I looked for this to replicate the behavior of Xcode; now I know my way around Emacs a bit better, in part thanks to Mickey Petersen’s “Demystifying Emacs’s Window Manager”, so I am now able to wield a more complex tool.