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: Sat, 27 Oct 2018 23:09:53 +0300 Organization: LINKOV.NET Message-ID: <87r2gbb85y.fsf@mail.linkov.net> References: <875zyrrhk8.fsf@mail.linkov.net> <87ftxgqcx0.fsf@mail.linkov.net> <5BBC5C61.4090901@gmx.at> <87ftx79brv.fsf@mail.linkov.net> <5BC5A536.7020603@gmx.at> <8736t57jcs.fsf@mail.linkov.net> <5BC6E559.3090000@gmx.at> <87zhvcteuy.fsf@mail.linkov.net> <5BC83EE4.8030607@gmx.at> <87h8hig9uw.fsf@mail.linkov.net> <5BC98A5F.5050807@gmx.at> <87ftx0nvoi.fsf@mail.linkov.net> <5BCC374E.603@gmx.at> <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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540671556 22765 195.159.176.226 (27 Oct 2018 20:19:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2018 20:19:16 +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 Sat Oct 27 22:19:12 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 1gGV39-0005pe-Tp for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 22:19:12 +0200 Original-Received: from localhost ([::1]:37687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGV5G-00079F-Dj for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2018 16:21:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGV51-00077M-JL for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:21:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGV4x-0006Ww-Ju for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:21:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gGV4x-0006Wc-Cp for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gGV4x-00007z-8F for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2018 16:21:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Oct 2018 20:21:03 +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.1540671631395 (code B ref 32850); Sat, 27 Oct 2018 20:21:03 +0000 Original-Received: (at 32850) by debbugs.gnu.org; 27 Oct 2018 20:20:31 +0000 Original-Received: from localhost ([127.0.0.1]:45785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGV4R-00006J-B7 for submit@debbugs.gnu.org; Sat, 27 Oct 2018 16:20:31 -0400 Original-Received: from cichlid.maple.relay.mailchannels.net ([23.83.214.36]:34823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGV4N-00005s-HQ for 32850@debbugs.gnu.org; Sat, 27 Oct 2018 16:20:28 -0400 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 0D5E8682C47; Sat, 27 Oct 2018 20:20:26 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a3.g.dreamhost.com (unknown [100.96.20.98]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C8C24682F9E; Sat, 27 Oct 2018 20:20:25 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a3.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); Sat, 27 Oct 2018 20:20:26 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Dime-Spot: 256efcb1237b7a4f_1540671625907_676887137 X-MC-Loop-Signature: 1540671625907:1705074760 X-MC-Ingress-Time: 1540671625906 Original-Received: from pdx1-sub0-mail-a3.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a3.g.dreamhost.com (Postfix) with ESMTP id 97F1A7F694; Sat, 27 Oct 2018 13:20:25 -0700 (PDT) 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=B+TOg5JP5QLjS6f0PjBGlbjAV2Y=; b= 2tnji48EFDYFZuTQU2FwIqq20JeWVu2wFiIuZv1UnamfQdH5O2eSE0Cwzr14cGG0 ciZUFR/GuRU+2ofydc/pfIj55xaTRDhFiV18Pwvc8tOgd/HcHWtQcgbQiD4B3flO gjFu3R1XMeWE+0R0hrOrbAR9BkMvZc/tgVSDBwKnCBs= Original-Received: from mail.jurta.org (m91-129-105-154.cust.tele2.ee [91.129.105.154]) (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-a3.g.dreamhost.com (Postfix) with ESMTPSA id 7447C7F68E; Sat, 27 Oct 2018 13:20:24 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a3 In-Reply-To: <5BD2C4AD.3060402@gmx.at> (martin rudalics's message of "Fri, 26 Oct 2018 09:39:25 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrheeggdduhedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdehrdduheegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddthedrudehgedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehruhgurghlihgtshesghhmgidrrghtnecuvehluhhsthgvrhfuihiivgeptd 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:151702 Archived-At: >> But unfortunately set-window-configuration doesn't restore >> the old values of prev/next-buffers. > > That's disputable anyway. When, in a window excursion, you show some > buffer in a window, don't you want to record that buffer in that > window's list of previous buffers after exiting from the excursion? Thanks for the hint, I see now that the problem is not in set-window-configuration, but in window-state-put. In case of set-window-configuration, `(set-window-next-buffers nil nil)' correctly changes the value of window-next-buffers in the same window that was stored in window-configuration and that is currently selected, i.e. this produces the right result when prev/next-buffers are modified in a new window (so not in the window shared in window configurations): (progn (set-buffers) ;; Remember window-configuration with prev/next-buffers (let ((window-configuration (current-window-configuration))) ;; Create a new window (delete-other-windows) (split-window) (delete-window) ;; Reset prev/next-buffers (set-window-prev-buffers nil nil) (set-window-next-buffers nil nil) ;; This correctly restores remembered prev/next-buffers ;; because window-next-buffers are modified in another window (set-window-configuration window-configuration) ;; window-prev-buffers and window-next-buffers are correct (list (window-prev-buffers) (window-next-buffers)))) But window-state-put has such deficiency with its undocumented prerequisite that a new unique window should be created manually before calling window-state-put to put the state into a new window (to not share it with other window configurations). This means a need in such ugly hack: ;; Create a new window (delete-other-windows) (split-window) (delete-window) ;; Put a previous state into the new window ;; to not share it with other window configurations (window-state-put previously-saved-window-state nil 'safe) ;; Get its window configuration (current-window-configuration) Please confirm is `(delete-other-windows) (split-window) (delete-window)' is the right idiom to create a new window to put the window state into, or there is a special function to create a window, that I can't find. > Anyway. It would be tedious but probably not impossible to provide a > function that transforms a configuration into a state. Doing the > opposite is conceptually questionable, at the very least. The code above does the opposite, but it requires an ugly workaround for window-state-put. > A basic invariant of the windows code is that a valid window cannot > appear twice on the same or a different frame. It may, however, > appear an arbitrary number of times in stored window configurations. Like the earlier code snippet demonstrates it causes problems when the same window appears an arbitrary number of times in stored window configurations. Thus the need to create a new window to put the state into (currently window-state-put itself doesn't create a new unique window).