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

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 24 Apr 2023 11:51:01 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
62427: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62427
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#62427: tab-bar-new-tab-to now handles cases with multiple side-windows
From: Eli Zaretskii <[email-masked]>
To: Juri Linkov <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Mon, 24 Apr 2023 14:50:38 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 23 Apr 2023 19:39:10 +0300
> 
> >> >> On a side-note (side-window? haha), I've got a patch that side-steps
> >> >> (hehe) the issue of modifying the 'window-side parameter completely, by
> >> >> binding to window--sides-inhibit-check to t.
> >> >
> >> > Thanks, window--sides-inhibit-check is a good find.
> >> > Let me test it for a while.
> >>
> >> I still can't find a test case that could be fixed by
> >> window--sides-inhibit-check.  Your original test case is fixed
> >> because you removed (set-window-parameter nil 'window-side nil).
> >> And the test case in bug#53662 doesn't need this line because
> >> it was fixed by adding (ignore-window-parameters t).
> >>
> >> But maybe there are cases where window--sides-inhibit-check
> >> would help, so we could add it as a precaution.
> >
> > Should I install the last patch, or should I wait for more testing?
> 
> The patch works in two known test cases, and no more tests were found,
> so probably it could be installed.

Thanks, installed on emacs-29 branch, and closing the bug.

Benson, any news on your copyright assignment?

Subject: tab-bar-new-tab-to now handles cases with multiple side-windows
From: Benson Chu <[email-masked]>
To: [email-masked]
Date: Fri, 24 Mar 2023 16:07:22 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

I've noticed that when I call #'tab-bar-new-tab while I'm in a
side-window that has siblings, I get an error from
#'window--sides-check, which happens when #'tab-bar-new-tab calls
#'delete-other-windows. Here's an example of my problem:

(progn
  (display-buffer-in-side-window (get-buffer-create "*hello*")
                                 '((side . right)
                                   (slot . 1)))
  (select-window
   (display-buffer-in-side-window (get-buffer-create "*world*")
                                  '((side . right)
                                    (slot . 2))))
  (tab-bar-new-tab))

The attached patch fixes this issue. Could it be applied to the emacs-29
branch?

Thanks!
>From cc8974b45d5726a0f6a8d9ab6566411c118a0769 Mon Sep 17 00:00:00 2001
From: Benson Chu <[email-masked]>
Date: Fri, 24 Mar 2023 15:38:03 -0500
Subject: [PATCH] tab-bar-new-tab-to now handles cases with multiple
 side-windows

Previously, calling tab-bar-new-tab-to only removes the 'window-side
property on the currently selected window, and then a call to
delete-other-windows was made to ensure that the selected window was
the only window.

However, if there are other side-windows (with the same side) present,
the call to delete-other-windows will fail on the
window--sides-check. This is because according to the check, all
windows on the same side should have the same 'window-side, and
because we only removed the 'window-side parameters on one of the
windows, there will be inconsistencies with that window and its parent
and siblings. Because of this, the call to delete-other-windows to
fail.

This patch makes sure that all windows on a given side will have
'window-side set to nil, so that the call to delete-other-windows will
not fail.

* lisp/tab-bar.el: remove 'window-side from selected window, window's
parent, and all window's siblings.
---
 lisp/tab-bar.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index dce6fa735fc..f05abffbcdb 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1556,7 +1556,13 @@ tab-bar-new-tab-to
       ;; with `delete-other-windows' and `split-window'.
       (unless (eq tab-bar-new-tab-choice 'clone)
         (set-window-parameter nil 'window-atom nil)
-        (set-window-parameter nil 'window-side nil))
+        (let ((side (window-parameter nil 'window-side)))
+          (when side
+            (walk-window-tree
+             (lambda (window)
+               (when (eq side (window-parameter window 'window-side))
+                 (set-window-parameter window 'window-side nil)))
+             nil t))))
       (let ((ignore-window-parameters t))
         (if (eq tab-bar-new-tab-choice 'clone)
             ;; Create new unique windows with the same layout
-- 
2.40.0