commit 2f987e42f1eb9daf864285d5a51de69ed4743b04
parent 2c4ca8908b6a737dd18c35057e096ce109a21911
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date: Sat, 29 Oct 2022 12:46:55 +0200
Adapt my/centered-mode to split-root-window-right
(window-buffer window-to-split) returns nil in that case, because
window-to-split is the root of the "window tree" rather than a "leaf"
or "live" window with an actual buffer attached to it.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/.emacs b/.emacs
@@ -129,8 +129,12 @@
(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)))
+ (let ((windows (if (frame-root-window-p window-to-split)
+ (window-list)
+ (list window-to-split))))
+ (dolist (w windows)
+ (when (buffer-local-value 'my/centered-mode (window-buffer w))
+ (set-window-margins w nil nil)))))
(advice-add 'split-window-right :before 'my/centered--undo-margins)