unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included
@ 2023-07-01 19:48 JD Smith
  2023-07-06  7:24 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: JD Smith @ 2023-07-01 19:48 UTC (permalink / raw)
  To: 64405


From a fresh Emacs 28 emacs -Q:

(progn
  (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1)))
  (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0)))
  (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1)))
  (window-toggle-side-windows)
  (window-toggle-side-windows))

Leads to the error `Specified root is not an ancestor of specified window’.  This arises as:

Debugger entered--Lisp error: (error "Specified root is not an ancestor of specified win...")
  delete-other-windows-internal(nil #<window 16>)
  window-state-put((((min-height . 4) (min-width . 10) (min-height-ignore . 2) (min-width-ignore . 7) (min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 64) (min-pixel-width . 70) (min-pixel-height-ignore . 32) (min-pixel-width-ignore . 49) (min-pixel-height-safe . 16) (min-pixel-width-safe . 14)) leaf (pixel-width . 591) (pixel-height . 560) (total-width . 84) (total-height . 35) (normal-height . 1.0) (normal-width . 1.0) (parameters (clone-of . #<window 3 on *scratch*>)) (buffer #<buffer *scratch*> (selected . t) (hscroll . 0) (fringes 8 8 nil nil) (margins nil) (scroll-bars nil 3 t nil 0 t nil) (vscroll . 0) (dedicated) (point . #<marker at 480 in *scratch*>) (start . #<marker at 1 in *scratch*>))) #<window 16>)
  window-toggle-side-windows()
  (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows))
  (progn (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows)))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

Strangely no error is seen with 1 or 2 side windows.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included
  2023-07-01 19:48 bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included JD Smith
@ 2023-07-06  7:24 ` Eli Zaretskii
  2023-07-07 13:56   ` martin rudalics
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-07-06  7:24 UTC (permalink / raw)
  To: JD Smith, martin rudalics; +Cc: 64405

> From: JD Smith <jdtsmith@gmail.com>
> Date: Sat, 1 Jul 2023 15:48:25 -0400
> 
> 
> From a fresh Emacs 28 emacs -Q:
> 
> (progn
>   (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1)))
>   (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0)))
>   (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1)))
>   (window-toggle-side-windows)
>   (window-toggle-side-windows))
> 
> Leads to the error `Specified root is not an ancestor of specified window’.  This arises as:
> 
> Debugger entered--Lisp error: (error "Specified root is not an ancestor of specified win...")
>   delete-other-windows-internal(nil #<window 16>)
>   window-state-put((((min-height . 4) (min-width . 10) (min-height-ignore . 2) (min-width-ignore . 7) (min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 64) (min-pixel-width . 70) (min-pixel-height-ignore . 32) (min-pixel-width-ignore . 49) (min-pixel-height-safe . 16) (min-pixel-width-safe . 14)) leaf (pixel-width . 591) (pixel-height . 560) (total-width . 84) (total-height . 35) (normal-height . 1.0) (normal-width . 1.0) (parameters (clone-of . #<window 3 on *scratch*>)) (buffer #<buffer *scratch*> (selected . t) (hscroll . 0) (fringes 8 8 nil nil) (margins nil) (scroll-bars nil 3 t nil 0 t nil) (vscroll . 0) (dedicated) (point . #<marker at 480 in *scratch*>) (start . #<marker at 1 in *scratch*>))) #<window 16>)
>   window-toggle-side-windows()
>   (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows))
>   (progn (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows)))
>   elisp--eval-last-sexp(nil)
>   eval-last-sexp(nil)
>   funcall-interactively(eval-last-sexp nil)
>   command-execute(eval-last-sexp)
> 
> Strangely no error is seen with 1 or 2 side windows.

Martin, any ideas or comments?  This still happens in Emacs 29 and
Emacs 30.

Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included
  2023-07-06  7:24 ` Eli Zaretskii
@ 2023-07-07 13:56   ` martin rudalics
  2023-07-08  9:06     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: martin rudalics @ 2023-07-07 13:56 UTC (permalink / raw)
  To: Eli Zaretskii, JD Smith; +Cc: 64405

[-- Attachment #1: Type: text/plain, Size: 2650 bytes --]

 >>  From a fresh Emacs 28 emacs -Q:
 >>
 >> (progn
 >>    (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1)))
 >>    (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0)))
 >>    (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1)))
 >>    (window-toggle-side-windows)
 >>    (window-toggle-side-windows))
 >>
 >> Leads to the error `Specified root is not an ancestor of specified window’.  This arises as:
 >>
 >> Debugger entered--Lisp error: (error "Specified root is not an ancestor of specified win...")
 >>    delete-other-windows-internal(nil #<window 16>)
 >>    window-state-put((((min-height . 4) (min-width . 10) (min-height-ignore . 2) (min-width-ignore . 7) (min-height-safe . 1) (min-width-safe . 2) (min-pixel-height . 64) (min-pixel-width . 70) (min-pixel-height-ignore . 32) (min-pixel-width-ignore . 49) (min-pixel-height-safe . 16) (min-pixel-width-safe . 14)) leaf (pixel-width . 591) (pixel-height . 560) (total-width . 84) (total-height . 35) (normal-height . 1.0) (normal-width . 1.0) (parameters (clone-of . #<window 3 on *scratch*>)) (buffer #<buffer *scratch*> (selected . t) (hscroll . 0) (fringes 8 8 nil nil) (margins nil) (scroll-bars nil 3 t nil 0 t nil) (vscroll . 0) (dedicated) (point . #<marker at 480 in *scratch*>) (start . #<marker at 1 in *scratch*>))) #<window 16>)
 >>    window-toggle-side-windows()
 >>    (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows))
 >>    (progn (progn (display-buffer-in-side-window (get-buffer-create "AA") '((side . right) (slot . -1))) (display-buffer-in-side-window (get-buffer-create "BB") '((side . right) (slot . 0))) (display-buffer-in-side-window (get-buffer-create "CC") '((side . right) (slot . 1))) (window-toggle-side-windows) (window-toggle-side-windows)))
 >>    elisp--eval-last-sexp(nil)
 >>    eval-last-sexp(nil)
 >>    funcall-interactively(eval-last-sexp nil)
 >>    command-execute(eval-last-sexp)
 >>
 >> Strangely no error is seen with 1 or 2 side windows.
 >
 > Martin, any ideas or comments?  This still happens in Emacs 29 and
 > Emacs 30.

The bug is an immediate consequence of my ill-advised "fix" for
Bug#50867.  A better fix for both bugs should be the attached one.
Please test it for the scenarios of Bug#50867 and the present one.

martin

[-- Attachment #2: window-state-put.diff --]
[-- Type: text/x-patch, Size: 1348 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index 16f16a75418..145558bb773 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6169,7 +6169,14 @@ window--state-put-1
       (let* ((horizontal (eq type 'hc))
 	     (total (window-size window horizontal pixelwise))
              (first t)
-             (window-combination-limit (cdr (assq 'combination-limit state)))
+	     ;; Make sure to make a new parent window for a horizontal
+	     ;; or vertical combination embedded in one of the same type
+	     ;; (see Bug#50867 and Bug#64405).
+	     (window-combination-limit
+	      (and (or (eq (cdr (assq 'combination-limit state)) t)
+		       (and horizontal (window-combined-p window t))
+		       (and (not horizontal) (window-combined-p window)))
+		   t))
 	     size new)
 	(dolist (item state)
 	  ;; Find the next child window.  WINDOW always points to the
@@ -6409,7 +6416,10 @@ window-state-put
 			   head)))
 	 (min-width (cdr (assq
 			  (if pixelwise 'min-pixel-width 'min-weight)
-			  head))))
+			  head)))
+	 ;; Bind the following two variables.  `window--state-put-1' has
+	 ;; to fully control them (see Bug#50867 and Bug#64405).
+	 window-combination-limit window-combination-resize)
     (if (and (not totals)
 	     (or (> min-height (window-size window nil pixelwise))
 		 (> min-width (window-size window t pixelwise)))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included
  2023-07-07 13:56   ` martin rudalics
@ 2023-07-08  9:06     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2023-07-08  9:06 UTC (permalink / raw)
  To: martin rudalics; +Cc: 64405-done, jdtsmith

> Date: Fri, 7 Jul 2023 15:56:22 +0200
> Cc: 64405@debbugs.gnu.org
> From: martin rudalics <rudalics@gmx.at>
> 
> The bug is an immediate consequence of my ill-advised "fix" for
> Bug#50867.  A better fix for both bugs should be the attached one.
> Please test it for the scenarios of Bug#50867 and the present one.

Thanks, tested successfully and installed on master.  Closing the bug.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-08  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01 19:48 bug#64405: `toggle-side-windows' with 3 or more side windows leads to error; reproducer included JD Smith
2023-07-06  7:24 ` Eli Zaretskii
2023-07-07 13:56   ` martin rudalics
2023-07-08  9:06     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).