unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 46904@debbugs.gnu.org
Subject: bug#46904: Non-unique windows produced by window-state-put
Date: Sun, 07 Mar 2021 20:43:40 +0200	[thread overview]
Message-ID: <87pn0bj617.fsf@mail.linkov.net> (raw)
In-Reply-To: <9bd9f7dd-a4d5-6d64-f784-f63f532efa10@gmx.at> (martin rudalics's message of "Fri, 5 Mar 2021 10:10:31 +0100")

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

>> Actually with this patch window-swap-states fails with the error
>> "Wrong type argument: stringp, nil" in:
>>
>>        ;; Swap basic states.
>>        (window-state-put state-1 window-2 t)
>>        (window-state-put state-2 window-1 t)
>>        ;; Swap overlays with `window' property.
>>        (with-current-buffer (window-buffer window-1)
>>
>> Here '(window-buffer window-1)' returns nil because
>> window-1 doesn't exist anymore after calling window-state-put.
>
> We could easily handle that by having `window-state-put' return the
> window actually used for putting the state into and use that in
> `window-swap-states'.  Yet someone else might use `window-state-put' in
> much the same way as `window-swap-states' does and we have a quite
> incompatible change: We nowhere say that the window used as second
> argument of `window-state-put' will be live if it was so before, but we
> neither say that it can be deleted.  So I'm not sure what to do ...

Indeed, this would be an incompatible change.

So better to fix callers not to use frame-root-window
that is unreliable: sometimes frame-root-window returns
an internal window, sometimes a live window:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: window-state-put-without-frame-root-window.patch --]
[-- Type: text/x-diff, Size: 397 bytes --]

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 917b5e496b..a7d905184b 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -766,7 +772,7 @@ tab-bar-select-tab
                      tab-bar-history-forward)))
 
          (ws
-          (window-state-put ws (frame-root-window (selected-frame)) 'safe)))
+          (window-state-put ws nil 'safe)))
 
         (setq tab-bar-history-omit t)
 

  reply	other threads:[~2021-03-07 18:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 20:13 bug#46904: Non-unique windows produced by window-state-put Juri Linkov
2021-03-04  8:35 ` martin rudalics
2021-03-04  9:39   ` Juri Linkov
2021-03-04 10:34     ` martin rudalics
2021-03-04 17:57       ` Juri Linkov
2021-03-04 20:31         ` Juri Linkov
2021-03-05  9:10           ` martin rudalics
2021-03-07 18:43             ` Juri Linkov [this message]
2021-03-08  8:26               ` martin rudalics
2021-03-08 17:18                 ` Juri Linkov
2021-03-08 18:06                   ` martin rudalics
2021-03-08 18:24                     ` Juri Linkov
2021-03-09 17:28                       ` Juri Linkov
2021-04-27 17:19   ` Juri Linkov
2021-04-28 20:25     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pn0bj617.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=46904@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).