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: Thu, 25 Oct 2018 02:39:45 +0300 Organization: LINKOV.NET Message-ID: <87lg6map8e.fsf@mail.linkov.net> References: <875zyrrhk8.fsf@mail.linkov.net> <871s9e1syw.fsf@mail.linkov.net> <5BB082A6.6040709@gmx.at> <87o9cepxfv.fsf@mail.linkov.net> <5BB1DC5D.2070903@gmx.at> <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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540424709 2874 195.159.176.226 (24 Oct 2018 23:45:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 24 Oct 2018 23:45:09 +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 Thu Oct 25 01:45:04 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 1gFSpj-0000dO-6P for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Oct 2018 01:45:03 +0200 Original-Received: from localhost ([::1]:51130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFSrp-00056K-Nc for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Oct 2018 19:47:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFSrj-00056F-7E for bug-gnu-emacs@gnu.org; Wed, 24 Oct 2018 19:47:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFSrd-0003KY-Tc for bug-gnu-emacs@gnu.org; Wed, 24 Oct 2018 19:47:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gFSrd-0003KQ-Pa for bug-gnu-emacs@gnu.org; Wed, 24 Oct 2018 19:47:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gFSrd-0001cj-Ma for bug-gnu-emacs@gnu.org; Wed, 24 Oct 2018 19:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Oct 2018 23:47:01 +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.15404247636166 (code B ref 32850); Wed, 24 Oct 2018 23:47:01 +0000 Original-Received: (at 32850) by debbugs.gnu.org; 24 Oct 2018 23:46:03 +0000 Original-Received: from localhost ([127.0.0.1]:41030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFSqh-0001bO-Bv for submit@debbugs.gnu.org; Wed, 24 Oct 2018 19:46:03 -0400 Original-Received: from gecko.birch.relay.mailchannels.net ([23.83.209.66]:60920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFSqf-0001aU-Up for 32850@debbugs.gnu.org; Wed, 24 Oct 2018 19:46:02 -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 3D1A7283726; Wed, 24 Oct 2018 23:46:00 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a38.g.dreamhost.com (unknown [100.96.16.121]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F2B3A28367D; Wed, 24 Oct 2018 23:45:59 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a38.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); Wed, 24 Oct 2018 23:46:00 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Coil-Towering: 6f35345c6fc46879_1540424760096_2259511442 X-MC-Loop-Signature: 1540424760096:2033410486 X-MC-Ingress-Time: 1540424760096 Original-Received: from pdx1-sub0-mail-a38.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a38.g.dreamhost.com (Postfix) with ESMTP id BE918803BD; Wed, 24 Oct 2018 16:45:59 -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=C9BUXji3Ez5qH1A9dhOqPseQ614=; b= ix0360i2C5d4kj9xqXt/OmEM8BX4Vq6efyCL2+p3j4OrPHSluFkQokW5wcN/PYkK auDkhT0VlouNKy3woJcx1UR6E13p20YMU5MT1B2U6cuwWWmr5uCO1HNnIwZTF0/M 70jViVaToYyOp+2zTKJXhocbTIsa5dpWkLw+5oE1e6I= 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-a38.g.dreamhost.com (Postfix) with ESMTPSA id 1354D803A3; Wed, 24 Oct 2018 16:45:57 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a38 In-Reply-To: <5BD03F21.6040807@gmx.at> (martin rudalics's message of "Wed, 24 Oct 2018 11:45:05 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrgeekgddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddthedrudehgeenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrddutdehrdduheegpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtoheprhhuuggrlhhitghssehgmhigrdgrthenucevlhhushhtvghrufhiiigvpedt 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:151580 Archived-At: >> Then we desperately need functions that will serialize window >> configurations to writable window states to save them in the >> desktop file. > > What's wrong with > > (save-window-excursion > (set-window-configuration configuration) > (window-state-get nil t)) Is it really a good solution for serialization of tens of window configurations? Is such code suitable to be placed to desktop.el? (let (window-configurations window-states current-window-configuration ;; Let-bind there hooks to nil to prevent them from running (window-configuration-change-hook nil) (window-size-change-functions nil)) ;; As an example, populate a list of window configurations. ;; In reality, all these configurations are different. (dotimes (_ (+ 10 (random 10))) (push (current-window-configuration) window-configurations)) ;; Preserve the current window configuration (setq current-window-configuration (current-window-configuration)) ;; Serialize window configurations for saving in the desktop file (setq window-states (mapcar (lambda (window-configuration) (save-window-excursion (set-window-configuration window-configuration) (window-state-get nil t))) window-configurations)) ;; Restore the previous window-configuration (set-window-configuration current-window-configuration) ;; Now window-states can be saved to the desktop file ;; Restore window-states from the desktop file ;; First, preserve the current window configuration (setq current-window-configuration (current-window-configuration)) ;; Restore the saved list from the desktop file (setq window-configurations (mapcar (lambda (window-state) (save-window-excursion (window-state-put window-state nil 'safe) (current-window-configuration))) window-states)) ;; Restore the previous window-configuration (set-window-configuration current-window-configuration) ;; Now window-configurations are available for another session window-configurations) While testing without let-binding window-configuration-change-hook to nil, window-configuration-change-hook was called 50 times, observable with: (add-hook 'window-configuration-change-hook (lambda () (message "window-configuration-change-hook called"))) when let-bound to nil, these hooks are not called. But after let-binding window-size-change-functions to nil, and testing with (add-hook 'window-size-change-functions (lambda (_) (message "window-size-change-functions called"))) window-size-change-functions is still called once. I don't understand why.