RSS | Source | License

Manage Windows in Emacs

Managing windows in Emacs seems complicated. There exists a ton of commands and packages and the windows are still messy. From my experience, all you need is the following commands:

Moves to the window in direction.
C-x 1
Expand selected window to maximum.
C-x 2
Split window vertically.
C-x 3
Split window horizontally.
Merge all siblings of selected window.
(requires buffer-move) buf-move
Moves buffer to the window in direction.
Go back/forward in window configuration history.

Code for luna-expand-window:

(defun luna-window-sibling-list (&optional window)
  "Return all siblings of WINDOW or selected window."
  (let* ((parent (window-parent window))
         (win (window-child parent))
    (while win
      (push win lst)
      (setq win (window-next-sibling win)))
    (remove (or window (selected-window)) lst)))

(defun luna-expand-window ()
  "Delete all sibling windows."
  (mapc #'delete-window (luna-window-sibling-list)))

Some related configurations:

# always pop window to right
(setq split-height-threshold              nil
      split-width-threshold               80)
# dont pop new frames
(setq ns-pop-up-frames nil)

Written by Yuan Fu

First Published on 2019-08-03 Sat 13:39

Last modified on 2020-09-12 Sat 16:10

Send your comment to archive.casouri.cat@gmail.com