summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2022-10-29 12:46:55 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2022-10-29 12:51:01 +0200
commit2f987e42f1eb9daf864285d5a51de69ed4743b04 (patch)
tree7f945c67e5c00ca1ee68cce14b4dad4f1b23e140
parent2c4ca8908b6a737dd18c35057e096ce109a21911 (diff)
downloaddotfiles-2f987e42f1eb9daf864285d5a51de69ed4743b04.tar.xz
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.
-rw-r--r--.emacs8
1 files changed, 6 insertions, 2 deletions
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)