Subject: bug#64451: 30.0.50; split-root-window-right ignores side windows

From: martin rudalics <[email-masked]>
Date: Fri, 7 Jul 2023 15:57:12 +0200

>> (display-buffer "*scratch*" '(display-buffer-in-side-window . ((side . right))))
 >> M-x split-root-window-right
 >>
 >> I would expect the new window to be to the left of the side window (I
 >> know this is counter-intuitive to splititng the root window, but it's
 >> also intuitive given the nature of side windows...)
 >>
 >> I don't know if this is intentional. I also don't know if it's a
 >> regression as it's not behavior I remember seeing until fairly recently.
 >
 > Martin, any comments?

There are two bugs.  The first one is that splitting a root window with
side windows is always an error unless a new side window on another side
should be made.  This should be fixed by the attached patch.

The second bug is that the 'split-root-window-...' functions probably
should split 'window-main-window' on that frame instead.  I'd rather
leave the fix for that to the people who wrote those functions.

martin

diff --git a/lisp/window.el b/lisp/window.el
index 16f16a75418..0ddd04b0696 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5434,6 +5434,10 @@ split-window
 	     (setq atom-root (window-atom-root window))
 	     (not (eq atom-root window)))
 	(throw 'done (split-window atom-root size side pixelwise)))
+       ((and (eq window (frame-root-window frame))
+	     (not (eq window-combination-resize 'side))
+	     (window-with-parameter 'window-side nil frame))
+	(error "Cannot split root window with side windows"))
        ;; If WINDOW is a side window or its first or last child is a
        ;; side window, throw an error unless `window-combination-resize'
        ;; equals 'side.