From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46904: Non-unique windows produced by window-state-put Date: Tue, 27 Apr 2021 20:19:21 +0300 Message-ID: <87im47myqu.fsf@mail.linkov.net> References: <877dmo0zdn.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36079"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 46904@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 27 19:58:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lbRyP-0009Ib-Qg for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 19:58:13 +0200 Original-Received: from localhost ([::1]:40378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbRyO-0002LA-QX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Apr 2021 13:58:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbROQ-0003br-Uj for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 13:21:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbROQ-0003k0-Md for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 13:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lbROQ-0002Wo-IH for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2021 13:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Apr 2021 17:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46904 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 46904-submit@debbugs.gnu.org id=B46904.16195440559680 (code B ref 46904); Tue, 27 Apr 2021 17:21:02 +0000 Original-Received: (at 46904) by debbugs.gnu.org; 27 Apr 2021 17:20:55 +0000 Original-Received: from localhost ([127.0.0.1]:50799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbROJ-0002W4-Dk for submit@debbugs.gnu.org; Tue, 27 Apr 2021 13:20:55 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:32923) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbROH-0002Vm-RD for 46904@debbugs.gnu.org; Tue, 27 Apr 2021 13:20:54 -0400 X-Originating-IP: 91.129.102.166 Original-Received: from mail.gandi.net (m91-129-102-166.cust.tele2.ee [91.129.102.166]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id D508C240003; Tue, 27 Apr 2021 17:20:46 +0000 (UTC) In-Reply-To: (martin rudalics's message of "Thu, 4 Mar 2021 09:35:26 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205040 Archived-At: --=-=-= Content-Type: text/plain >> I don't know how severe are the consequences. The only side-effect I noticed >> that prev-buffers of restored windows are the same on different tabs because >> they share the same window. > > If that is a problem and the above would help, let's do it. It couldn't > possibly harm unless the root window is too small to get split and we > want to put only one window there; so we should handle that special case. The original problem was that prev-buffers of restored windows are the same on different tabs. This was fixed by always creating a new window. However, the same problem still exists, but for a different reason. Most windows have current buffer duplicated in prev-buffers. So when set-window-prev-buffers in window--state-put-2 sets prev-buffers to a list with only current buffer, this means as if there are no prev-buffers. But when a window has an empty list of prev-buffers, then the window parameter of prev-buffers is not cleared, and still contains a random buffer from some previous state. This patch fixes it: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=window--state-put-2-prev-buffers.patch diff --git a/lisp/window.el b/lisp/window.el index 036eb271ee..fc4ca303b0 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6140,7 +6140,8 @@ window--state-put-2 (setq buffer (get-buffer buffer)) (when (buffer-live-p buffer) buffer)) next-buffers)))) - (when prev-buffers + (if (not prev-buffers) + (set-window-prev-buffers window nil) (set-window-prev-buffers window (delq nil (mapcar (lambda (entry) --=-=-=--