Subject: Re: bug#62427: tab-bar-new-tab-to now handles cases with multiple side-windows

From: martin rudalics <[email-masked]>
Date: Wed, 17 May 2023 10:13:18 +0200

>> 0. emacs -Q
 >> 1. M-x
 >> 2. C-x t 2
 >> 3. C-x o     ;; switches to the minibuffer
 >> 4. C-x t 2
 >>
 >> Debugger entered--Lisp error: (error "Specified root is not an ancestor of specified win...")
 >>    delete-other-windows-internal(#<window 4 on  *Minibuf-1*> #<window 8 on *scratch*>)
 >>    delete-other-windows()
 >>    tab-bar-new-tab-to()
 >>    tab-new(nil)
 >>    funcall-interactively(tab-new nil)
 >>    command-execute(tab-new)
 >
 > Martin, could you please help to debug this problem.
 >
 > Does the error occur because the window configuration is broken?

No.  Binding 'ignore-window-parameters' to t skips the usual error
message that you "Can't expand minibuffer to full frame".  Does the
attached patch fix it?

martin

diff --git a/lisp/window.el b/lisp/window.el
index 016d53ffbdd..5994b6816ef 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4356,10 +4356,7 @@ delete-other-windows
 	    (error "Root of atomic window is root window of its frame")
 	  (throw 'done (delete-other-windows atom-root))))
        ((window-parameter window 'window-side)
-	(error "Cannot make side window the only window"))
-       ((and (window-minibuffer-p window)
-	     (not (eq window (frame-root-window window))))
-	(error "Can't expand minibuffer to full frame")))
+	(error "Cannot make side window the only window")))
 
       (cond
        ((or ignore-window-parameters
@@ -4395,15 +4392,21 @@ delete-other-windows
               (error nil))))
         (throw 'done nil)))
 
-      ;; If WINDOW is the main window of its frame do nothing.
-      (if (eq window main)
-          ;; Give a message to the user if this has been called as a
-          ;; command.
-          (when (and interactive
-                     (not (or executing-kbd-macro noninteractive)))
-            (message "No other windows to delete"))
+      (cond
+       ;; If WINDOW is the main window of its frame do nothing.
+       ((eq window main)
+        ;; Give a message to the user if this has been called as a
+        ;; command.
+        (when (and interactive
+                   (not (or executing-kbd-macro noninteractive)))
+          (message "No other windows to delete")))
+       ((and (window-minibuffer-p window)
+	     (not (eq window (frame-root-window window))))
+	(user-error "Can't expand minibuffer to full frame"))
+       (t
 	(delete-other-windows-internal window main)
-	(window--check frame))
+	(window--check frame)))
+
       ;; Always return nil.
       nil)))