From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers Date: Mon, 05 Nov 2018 23:38:27 +0200 Organization: LINKOV.NET Message-ID: <87ftwfyzq9.fsf@mail.linkov.net> References: <875zyrrhk8.fsf@mail.linkov.net> <87a7n7kz7x.fsf@mail.linkov.net> <5BCD935F.8030309@gmx.at> <87in1szirt.fsf@mail.linkov.net> <5BD03F21.6040807@gmx.at> <87lg6map8e.fsf@mail.linkov.net> <5BD15CE0.7080703@gmx.at> <87va5qf1ox.fsf@mail.linkov.net> <5BD2C4AD.3060402@gmx.at> <87r2gbb85y.fsf@mail.linkov.net> <5BD57AB5.2040105@gmx.at> <87woq2xn22.fsf@mail.linkov.net> <5BD6C86F.9030508@gmx.at> <878t2g74oq.fsf@mail.linkov.net> <5BD81DA2.4020003@gmx.at> <87k1lzruwe.fsf@mail.linkov.net> <5BD963B3.3080800@gmx.at> <877ehx95bz.fsf@mail.linkov.net> <5BDAC163.10606@gmx.at> <87sh0kig69.fsf@mail.linkov.net> <5BDC0E49.6020200@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1541454149 20980 195.159.176.226 (5 Nov 2018 21:42:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2018 21:42:29 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 32850@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 05 22:42:25 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJmdc-0005ME-Q6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Nov 2018 22:42:25 +0100 Original-Received: from localhost ([::1]:37722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJmfj-0005Nr-CA for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Nov 2018 16:44:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJmbN-000877-Vr for bug-gnu-emacs@gnu.org; Mon, 05 Nov 2018 16:40:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJmbK-00042u-M0 for bug-gnu-emacs@gnu.org; Mon, 05 Nov 2018 16:40:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJmbK-00042h-EO for bug-gnu-emacs@gnu.org; Mon, 05 Nov 2018 16:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gJmbK-000491-B0 for bug-gnu-emacs@gnu.org; Mon, 05 Nov 2018 16:40:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Nov 2018 21:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32850 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32850-submit@debbugs.gnu.org id=B32850.154145395415874 (code B ref 32850); Mon, 05 Nov 2018 21:40:02 +0000 Original-Received: (at 32850) by debbugs.gnu.org; 5 Nov 2018 21:39:14 +0000 Original-Received: from localhost ([127.0.0.1]:35787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJmaX-00047x-PV for submit@debbugs.gnu.org; Mon, 05 Nov 2018 16:39:14 -0500 Original-Received: from quail.birch.relay.mailchannels.net ([23.83.209.151]:51925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJmaV-00047p-IK for 32850@debbugs.gnu.org; Mon, 05 Nov 2018 16:39:12 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B3E20283A4C; Mon, 5 Nov 2018 21:39:10 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a31.g.dreamhost.com (unknown [100.96.19.78]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 7BFB2283A95; Mon, 5 Nov 2018 21:39:10 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a31.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Mon, 05 Nov 2018 21:39:10 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Continue-Arithmetic: 7d9b589a50af3770_1541453950602_1029092119 X-MC-Loop-Signature: 1541453950601:691661353 X-MC-Ingress-Time: 1541453950601 Original-Received: from pdx1-sub0-mail-a31.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a31.g.dreamhost.com (Postfix) with ESMTP id 4469D804D5; Mon, 5 Nov 2018 13:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=uzCUEFjsqwMTzJgQpyEdVnap8DY=; b= urL6wtFYIRNqhqXM5pN3uvVZKL2+fzsNmrXEvHSndmJWb+gA6Fdd5Os+Ws8+tpU5 Dt855olOHX9pVKBlHyOy0dW1hNz+ece/awp7lQTNJDeLA4Tj3olskcTcaiGX4oLF tkcGTaDXhiyA5mgRjvbRu5ds9VCq0PyEzmDPM1vbMco= Original-Received: from mail.jurta.org (m91-129-107-244.cust.tele2.ee [91.129.107.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a31.g.dreamhost.com (Postfix) with ESMTPSA id 2A076804CD; Mon, 5 Nov 2018 13:39:07 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a31 In-Reply-To: <5BDC0E49.6020200@gmx.at> (martin rudalics's message of "Fri, 02 Nov 2018 09:43:53 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrjeehgdduheefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdejrddvgeegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtjedrvdeggedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehruhgurghlihgtshesghhmgidrrghtnecuvehluhhsthgvrhfuihiivgepud X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152084 Archived-At: > Sounds reasonable (Bug#16793 just wants a live window there and > splitting and deleting the old one should do that trivially). Feel > free to install if you see no further problems. After reading bug#16793, I see that the original intention was to restore a window state on the same frame where the subtree of the specified internal window is. If this is important, then a better change is: diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 772bcdf9a6..49698f45bf 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -5706,9 +5706,10 @@ Window Configurations The argument @var{state} should be the state of a window returned by an earlier invocation of @code{window-state-get}, see above. The optional argument @var{window} can be either a live window or an -internal window (@pxref{Windows and Frames}) and defaults to the -selected one. If @var{window} is not live, it is replaced by a live -window before putting @var{state} into it. +internal window (@pxref{Windows and Frames}). If @var{window} is not +live, it is replaced by a new live window created on the same subtree +before putting @var{state} into it. If @var{window} is nil, it puts +the window state into a new window. If the optional argument @var{ignore} is non-@code{nil}, it means to ignore minimum window sizes and fixed-size restrictions. If @var{ignore} diff --git a/lisp/window.el b/lisp/window.el index bcd4fa2959..b8a8b81af3 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5889,29 +5889,34 @@ window-state-put "Put window state STATE into WINDOW. STATE should be the state of a window returned by an earlier invocation of `window-state-get'. Optional argument WINDOW must -specify a valid window and defaults to the selected one. If -WINDOW is not live, replace WINDOW by a live one before putting -STATE into it. +specify a valid window. If WINDOW is not live, replace WINDOW +by a new live one created on the same subtree. If WINDOW is nil, +create a new window before putting STATE into it. Optional argument IGNORE non-nil means ignore minimum window sizes and fixed size restrictions. IGNORE equal `safe' means windows can get as small as `window-safe-min-height' and `window-safe-min-width'." (setq window-state-put-stale-windows nil) - (setq window (window-normalize-window window)) - ;; When WINDOW is internal, reduce it to a live one to put STATE into, - ;; see Bug#16793. + ;; When WINDOW is internal or nil, reduce it to a live one, + ;; then create a new window on the same subtree to put STATE into. (unless (window-live-p window) (let ((root window)) - (setq window (catch 'live - (walk-window-subtree - (lambda (window) - (when (and (window-live-p window) - (not (window-parameter window 'window-side))) - (throw 'live window))) - root))) - (delete-other-windows-internal window root))) + (setq window (if root + (catch 'live + (walk-window-subtree + (lambda (window) + (when (and (window-live-p window) + (not (window-parameter + window 'window-side))) + (throw 'live window))) + root)) + (selected-window))) + (delete-other-windows-internal window root) + ;; Create a new window to replace the existing one. + (setq window (prog1 (split-window window) + (delete-window window))))) (set-window-dedicated-p window nil)