From 2f987e42f1eb9daf864285d5a51de69ed4743b04 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sat, 29 Oct 2022 12:46:55 +0200 Subject: 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. --- .emacs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to '.emacs') diff --git a/.emacs b/.emacs index e052b91..1359c84 100644 --- 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) -- cgit v1.2.3