From 89fa73ae2ab55eb9513a623fcf086115c398eec6 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 2 Oct 2022 17:15:35 +0200 Subject: Unset margins before attempting to split window Emacs seems to take margins into account when deciding whether a window can be split horizontally. So with my current personal config, a full-width Gnus article window would have huge margins, and could not be split horizontally because a half-width window would not have enough room for these margins. --- .emacs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.emacs b/.emacs index 75662f1..e052b91 100644 --- a/.emacs +++ b/.emacs @@ -128,6 +128,12 @@ (defvar-local my/centered-width 'fill-column) (defvar-local my/centered-set-right-margin nil) +(defun my/centered--undo-margins (&optional _size window-to-split) + (when (buffer-local-value 'my/centered-mode (window-buffer window-to-split)) + (set-window-margins window-to-split nil nil))) + +(advice-add 'split-window-right :before 'my/centered--undo-margins) + (define-minor-mode my/centered-mode "Update margins to keep content centered." :init-value nil -- cgit v1.2.3