* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
@ 2024-10-04 15:09 Nussbaum Ferdinand
2024-10-05 11:15 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Nussbaum Ferdinand @ 2024-10-04 15:09 UTC (permalink / raw)
To: 73627
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
To reproduce from emacs -Q, evaluate in the scratch buffer:
(display-buffer-in-side-window
(get-scratch-buffer-create)
'((side . left)))
(split-window (frame-root-window) nil 'below)
(window-main-window)
Observe that (window-main-window) returns the selected window. However, the
window that was created by splitting below is not a side window, and it does not
descend from the selected window. This contradicts part of the docstring of
window-main-window:
"If FRAME has no side windows, return FRAME's root window. Otherwise, return
either an internal non-side window such that all other non-side windows on FRAME
descend from it, or the single live non-side window of FRAME."
Splitting a frame's root window in the presence of side windows seems to often
lead to such discrepancies. I have observed such behaviour in the packages hydra
(on ELPA, in its lv-window function), and shell-pop (from another package
archive).
Related to that: Is the following supposed to be an invariant for each frame,
and should it be considered a bug when packages violate it?
Invariant:
There exists a window MAIN such that for all live windows WIN (other than MAIN)
we have: WIN descends from MAIN if and only if it is not a side window.
This is something I assumed and was surprised to see violated.
Best,
Ferdinand
[-- Attachment #2: Type: text/html, Size: 6862 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
2024-10-04 15:09 bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring Nussbaum Ferdinand
@ 2024-10-05 11:15 ` Eli Zaretskii
2024-10-05 14:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-10-05 11:15 UTC (permalink / raw)
To: Nussbaum Ferdinand, martin rudalics; +Cc: 73627
> From: "Nussbaum Ferdinand" <ferdinand.nussbaum@inf.ethz.ch>
> Date: Fri, 4 Oct 2024 15:09:18 +0000
>
> To reproduce from emacs -Q, evaluate in the scratch buffer:
>
> (display-buffer-in-side-window
> (get-scratch-buffer-create)
> '((side . left)))
> (split-window (frame-root-window) nil 'below)
> (window-main-window)
>
> Observe that (window-main-window) returns the selected window. However, the
> window that was created by splitting below is not a side window, and it does not
> descend from the selected window. This contradicts part of the docstring of
> window-main-window:
>
> "If FRAME has no side windows, return FRAME's root window. Otherwise, return
> either an internal non-side window such that all other non-side windows on FRAME
> descend from it, or the single live non-side window of FRAME."
>
> Splitting a frame's root window in the presence of side windows seems to often
> lead to such discrepancies. I have observed such behaviour in the packages hydra
> (on ELPA, in its lv-window function), and shell-pop (from another package
> archive).
>
> Related to that: Is the following supposed to be an invariant for each frame,
> and should it be considered a bug when packages violate it?
>
> Invariant:
> There exists a window MAIN such that for all live windows WIN (other than MAIN)
> we have: WIN descends from MAIN if and only if it is not a side window.
>
> This is something I assumed and was surprised to see violated.
Martin, any comments?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
2024-10-05 11:15 ` Eli Zaretskii
@ 2024-10-05 14:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 11:55 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-05 14:37 UTC (permalink / raw)
To: Eli Zaretskii, Nussbaum Ferdinand; +Cc: 73627
[-- Attachment #1: Type: text/plain, Size: 1843 bytes --]
>> To reproduce from emacs -Q, evaluate in the scratch buffer:
>>
>> (display-buffer-in-side-window
>> (get-scratch-buffer-create)
>> '((side . left)))
>> (split-window (frame-root-window) nil 'below)
>> (window-main-window)
>>
>> Observe that (window-main-window) returns the selected window. However, the
>> window that was created by splitting below is not a side window, and it does not
>> descend from the selected window. This contradicts part of the docstring of
>> window-main-window:
>>
>> "If FRAME has no side windows, return FRAME's root window. Otherwise, return
>> either an internal non-side window such that all other non-side windows on FRAME
>> descend from it, or the single live non-side window of FRAME."
This accusation is correct.
>> Splitting a frame's root window in the presence of side windows seems to often
>> lead to such discrepancies. I have observed such behaviour in the packages hydra
>> (on ELPA, in its lv-window function), and shell-pop (from another package
>> archive).
>>
>> Related to that: Is the following supposed to be an invariant for each frame,
>> and should it be considered a bug when packages violate it?
>>
>> Invariant:
>> There exists a window MAIN such that for all live windows WIN (other than MAIN)
>> we have: WIN descends from MAIN if and only if it is not a side window.
It should be an invariant and it is a bug when packages (or, as in the
case at hand Emacs itself) violate it.
>> This is something I assumed and was surprised to see violated.
>
> Martin, any comments?
Ferdinand is right. 'split-window' must split the frame's main window
instead of the root window. Patch attached. It should be OK for the
release version but I won't insist since the bug has been with us ever
since side windows exist.
Thanks for the report, martin
[-- Attachment #2: window.el.diff --]
[-- Type: text/x-patch, Size: 838 bytes --]
diff --git a/lisp/window.el b/lisp/window.el
index 006cfa19525..254814b989a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5455,6 +5455,13 @@ split-window
(setq atom-root (window-atom-root window))
(not (eq atom-root window)))
(throw 'done (split-window atom-root size side pixelwise)))
+ ;; If WINDOW's frame has a side window and WINDOW specifies the
+ ;; frame's root window, split the frame's main window instead
+ ;; (Bug#73627).
+ ((and (eq window (frame-root-window frame))
+ (window-with-parameter 'window-side nil frame))
+ (throw 'done (split-window (window-main-window frame)
+ size side pixelwise)))
;; 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.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
2024-10-05 14:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-12 11:55 ` Eli Zaretskii
2024-10-13 8:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-10-12 11:55 UTC (permalink / raw)
To: martin rudalics; +Cc: ferdinand.nussbaum, 73627
> Date: Sat, 5 Oct 2024 16:37:50 +0200
> Cc: 73627@debbugs.gnu.org
> From: martin rudalics <rudalics@gmx.at>
>
> Ferdinand is right. 'split-window' must split the frame's main window
> instead of the root window. Patch attached. It should be OK for the
> release version but I won't insist since the bug has been with us ever
> since side windows exist.
Thanks. Feel free to install on master (or tell me if you want me to
do that).
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
2024-10-12 11:55 ` Eli Zaretskii
@ 2024-10-13 8:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-20 8:34 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-13 8:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ferdinand.nussbaum, 73627
> Thanks. Feel free to install on master (or tell me if you want me to
> do that).
Installed on master.
Thanks, martin
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring
2024-10-13 8:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-10-20 8:34 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-10-20 8:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ferdinand.nussbaum, 73627-done
Version: 31.1
> Installed on master.
Closing this bug, martin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-20 8:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 15:09 bug#73627: 29.3; window-main-window: Discrepancy between behaviour and docstring Nussbaum Ferdinand
2024-10-05 11:15 ` Eli Zaretskii
2024-10-05 14:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 11:55 ` Eli Zaretskii
2024-10-13 8:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-20 8:34 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.