- Emacs Lisp 100%
| cairn.el | ||
| CLAUDE.md | ||
| README.md | ||
cairn
A stacking window manager for Emacs.
Claude has been used extensively for developing this package, do with that information what you will.
Emulation Map
Cairn uses an emulation map, to "hijack" your keybindings from things like Ghostel. The Cairn mode map can be (ab)used for other WM-related bindings that should work everywhere, for example popper.
TLDR
The basic idea is to replace C-x o with DWM-like motions to move
up and down a stack of windows, where the top window is always presented on the
left, and "the rest" up to a customizable limit is presented in a stack on the
right.
Cairn takes over display-buffer, splits the stack while there is room,
and after that uses the last window in the stack, unless using the same window is
explicitly asked for.
A window split for a buffer closes when the buffer is killed, so a terminal's
window goes away when its shell exits.
popper works alongside cairn. By default it shows popups in a side window, which cairn skips. To have popups go in the stack instead, let popper mark and toggle them, but not place them:
(setq popper-display-control nil)
Layouts
A stack is laid out one of three ways:
tile: master +cairn-stack-sizewindows on the rightpair: master + one window on the rightrows: master above one window, for narrow frames
A new stack goes below master if the frame is narrower than
split-width-threshold, and beside it otherwise. Resizing the frame leaves it
on that side. cairn-cycle-layout picks another layout for the stack, skipping
rows in wide frames; the pick lasts until the stack closes down to master.
Stack windows that don't fit are closed, and come back once there's room again.
(keymap-set cairn-map "M-m" #'cairn-cycle-layout)
cairn-mode-line shows the layout on master's mode line: 1+2, 1+1 or 0+2,
faded until picked. The faces are cairn-mode-line-auto and
cairn-mode-line-picked, and clicking it cycles the layout.
;; Not the bare symbol: first in a list, a symbol makes the list a conditional.
(add-to-list 'mode-line-misc-info '(cairn-mode cairn-mode-line))
Stack prefix
cairn-stack-prefix sends the next command's buffer to the stack, even when
the command asks for the current window. Like C-x 4 4, but placed the way
cairn places everything else, so it doesn't split windows of its own.
Side windows
Side windows sit outside master and the stack, like a dock: they take an edge
of the frame, and cairn's motions skip them.
Anything shown with display-buffer-in-side-window docks this way, e.g. treemacs.
cairn-side-windows manages side windows:
From a side window it goes back to the stack,
from anywhere else it toggles visibility.
(keymap-set cairn-map "M-e" #'cairn-side-windows)