From 1d3e91772a5379f91cbd7b1b25e6ef5a4354a041 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 22 Feb 2024 11:01:08 +0100 Subject: Add window management section. --- init.org | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/init.org b/init.org index 9ad8536..c9da884 100644 --- a/init.org +++ b/init.org @@ -919,6 +919,86 @@ Some customisations for =paredit=. TODO: the parentheses adjustments should happen only when I’m in programming mode. +* Window management + +I agree with this assessment of Emacs window splitting behavior in the README of the =perspective= package: + +#+BEGIN_QUOTE +Emacs has bad default behavior when it comes to window handling: many commands and modes have a habit of splitting existing windows and changing the user's carefully thought-out window layout. This tends to be a more serious problem for people who run Emacs on large displays (possibly in full-screen mode): the greater amount of screen real estate makes it easy to split the frame into many smaller windows, making any unexpected alterations more disruptive. +#+END_QUOTE + +We configure =display-buffer-alist= to reuse certain locations for buffers like documentation, compilation, etc. + +#+BEGIN_SRC elisp +(setq display-buffer-alist + '(;; top side window + ("\\*\\(Flycheck\\|Flymake\\|Package-Lint\\|vc-git :\\).*" + (display-buffer-in-side-window) + (window-height . 0.16) + (side . top) + (slot . 0) + (window-parameters + . ((no-other-window . t) + (mode-line-format . (" " + mode-line-buffer-identification))))) + ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|Messages\\)\\*" + (display-buffer-in-side-window) + (window-height . 0.16) + (side . top) + (slot . 1) + (window-parameters + . ((no-other-window . t) + (mode-line-format . (" " + mode-line-buffer-identification))))) + ;; bottom side window + (".*\\*Completions.*" + (display-buffer-in-side-window) + (window-height . 0.16) + (side . bottom) + (slot . 0) + (window-parameters . ((no-other-window . t)))) + ("\\*Org Agenda\\*" + (display-buffer-in-direction) + (direction . leftmost) + (window-width . 0.40) + (window-parameters + . ((mode-line-format . nil)))) + ("\\*\\(Help\\|Faces\\).*" + (display-buffer-in-side-window) + (side . left) + (slot . 0) + (window-width . 0.35) + (window-parameters . ((no-other-window . nil) + (mode-line-format . nil)))) + ;; bottom buffer (NOT side window) + ("\\*\\vc-\\(incoming\\|outgoing\\).*" + (display-buffer-at-bottom)) + + ;(".*" (reusable-frames . t)) + )) +(setq window-combination-resize t) +(setq even-window-sizes 'height-only) +(setq display-buffer-reuse-frames t) ; reuse windows in other frames + +;; If non-nil, left and right side windows occupy full frame height. +;; If nil, top and bottom side windows occupy full frame width. +(setq window-sides-vertical nil) +#+END_SRC + +The Help window might be a little too narrow, so we use a hook to switch to =visual-line-mode=: + +#+begin_src elisp +(add-hook 'help-mode-hook + (lambda () + (visual-line-mode 1))) +#+end_src + +Side windows cannot be navigated, so we need another mechanism to close them all. + +#+begin_src elisp +(global-set-key (kbd "C-x x") 'window-toggle-side-windows) +#+end_src + * Email TODO: this is a big blob of email configuration. Document this properly! -- cgit v1.2.3