commit 89fa73ae2ab55eb9513a623fcf086115c398eec6
parent e78bde323b1f62a6851c12e10e130215b0d08c3b
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date: Sun, 2 Oct 2022 17:15:35 +0200
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.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git 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