summaryrefslogtreecommitdiff
path: root/.emacs
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2022-10-02 17:15:35 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2022-10-02 17:21:39 +0200
commit89fa73ae2ab55eb9513a623fcf086115c398eec6 (patch)
treef8f07af8bf3ff8e7e2e41ad1c61be03b3e5f71d1 /.emacs
parente78bde323b1f62a6851c12e10e130215b0d08c3b (diff)
downloaddotfiles-89fa73ae2ab55eb9513a623fcf086115c398eec6.tar.xz
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 (limited to '.emacs')
-rw-r--r--.emacs6
1 files changed, 6 insertions, 0 deletions
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