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, 18 Oct 2018 00:58:29 +0300 Organization: LINKOV.NET Message-ID: <87zhvcteuy.fsf@mail.linkov.net> References: <875zyrrhk8.fsf@mail.linkov.net> <5BAD2538.1060609@gmx.at> <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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1539815325 11448 195.159.176.226 (17 Oct 2018 22:28:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 Oct 2018 22:28:45 +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 18 00:28:40 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 1gCuIt-0002lr-8L for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Oct 2018 00:28:40 +0200 Original-Received: from localhost ([::1]:39387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCuKz-000055-MZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Oct 2018 18:30:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCuKS-0008Bs-2j for bug-gnu-emacs@gnu.org; Wed, 17 Oct 2018 18:30:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCuKM-0000Dh-1x for bug-gnu-emacs@gnu.org; Wed, 17 Oct 2018 18:30:11 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCuKK-0000Ck-Kh for bug-gnu-emacs@gnu.org; Wed, 17 Oct 2018 18:30:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gCuKK-0003rm-FT for bug-gnu-emacs@gnu.org; Wed, 17 Oct 2018 18:30:04 -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, 17 Oct 2018 22:30:04 +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.153981536114729 (code B ref 32850); Wed, 17 Oct 2018 22:30:04 +0000 Original-Received: (at 32850) by debbugs.gnu.org; 17 Oct 2018 22:29:21 +0000 Original-Received: from localhost ([127.0.0.1]:55929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCuJc-0003pV-Vv for submit@debbugs.gnu.org; Wed, 17 Oct 2018 18:29:21 -0400 Original-Received: from pop.dreamhost.com ([64.90.62.162]:58060 helo=pdx1-sub0-mail-a75.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCuJb-0003pM-Mb for 32850@debbugs.gnu.org; Wed, 17 Oct 2018 18:29:20 -0400 Original-Received: from pdx1-sub0-mail-a75.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a75.g.dreamhost.com (Postfix) with ESMTP id 36997807EE; Wed, 17 Oct 2018 15:29:19 -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=xJZzA4pjlc9bDWfdNQFX3NJAxAw=; b= xHpTYLnFoHHPHv/oYgJrP3KU2kVkkUUf1TmySIY/D7JWNO30PTTuuPTFsbtpm6Kn S9e6hXKMfltVcEQDjuJu+E9MkQMzIi/1VFHnUovlhXtMpV6igQ9adfKhRuFYUH9L Q37qQUNFKdcY/l4/B8ZEAp51OLgOBMDf5RjRwG7HaLQ= Original-Received: from localhost.linkov.net (m91-129-96-249.cust.tele2.ee [91.129.96.249]) (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-a75.g.dreamhost.com (Postfix) with ESMTPSA id 41CFA807FE; Wed, 17 Oct 2018 15:29:16 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a75 In-Reply-To: <5BC6E559.3090000@gmx.at> (martin rudalics's message of "Wed, 17 Oct 2018 09:31:37 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrfeefgddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhfffgjkfgfgggtsehmtderredtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledrleeirddvgeelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehlohgtrghlhhhoshhtrdhlihhnkhhovhdrnhgvthdpihhnvghtpeeluddruddvledrleeirddvgeelpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtoheprhhuuggrlhhitghssehgmhigrdgrthenucevlhhushhtvghrufhiiigvpedt 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:151360 Archived-At: --=-=-= Content-Type: text/plain >> I'd like to make it customizable by using the existing customization in >> the arg WRITABLE of window-state-get and window-persistent-parameters, >> even though formally prev/next-buffers is not a window parameter (maybe >> it should be, I don't know). > > Always keep in mind that prev_buffers and next_buffers need special > treatment in mark_object to make sure that dead buffers from window > configurations stored somewhere (for example in a register) get their > entries deleted and can be eventually reclaimed. This is something I > completely disregarded when writing the original code for navigating > these buffer lists. Stefan then wrote the code to do that in > mark_object. When testing the previous patch, I noticed that killed buffers automatically disappear from prev/next-buffers lists, so there are no # remains. Is it handled by code in kill-buffer? >> Done, with a small change: even though set-marker is idempotent in regard >> to its POSITION arg (i.e. if POSITION is a marker, it creates an identical >> marker), I added a check to not create a new one. OTOH, get-buffer is >> idempotent too, but it seems window-state-put never receives a structure >> with buffer objects, and I'm not sure why window-state-get should always >> use buffer-name regardless of the value WRITABLE, i.e. why should it return >> buffer names as strings instead of buffer objects even when WRITABLE is nil? > > Maybe because I didn't care about non-writable states back then. But > you're obviously right. Buffers can be renamed at will and in that > case we might have a state with a non-existent buffer or even buffers > with names switched and therefore invalid values of start or point. What do you think about creating new functions to convert the existing states from non-writable to writable and back? Then in the same session it would be more optimal to use window states with buffer/mark objects, and states to save to the desktop could be serialized by such functions. > So yes: Please use a buffer object for non-writable states. Here is a new patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=window-state-prev-next-buffers.2.patch diff --git a/lisp/window.el b/lisp/window.el index a7318308ef..77b650fda9 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5579,7 +5579,7 @@ window--state-get-1 (let ((point (window-point window)) (start (window-start window))) `((buffer - ,(buffer-name buffer) + ,(if writable (buffer-name buffer) buffer) (selected . ,selected) (hscroll . ,(window-hscroll window)) (fringes . ,(window-fringes window)) @@ -5599,20 +5599,20 @@ window--state-get-1 (with-current-buffer buffer (copy-marker start)))))))) ,@(when next-buffers - `((next-buffers . ,(mapcar (lambda (buffer) - (buffer-name buffer)) - next-buffers)))) + `((next-buffers + . ,(if writable + (mapcar (lambda (buffer) (buffer-name buffer)) + next-buffers) + next-buffers)))) ,@(when prev-buffers - `((prev-buffers . - ,(mapcar (lambda (entry) - (list (buffer-name (nth 0 entry)) - (if writable - (marker-position (nth 1 entry)) - (nth 1 entry)) - (if writable - (marker-position (nth 2 entry)) - (nth 2 entry)))) - prev-buffers)))))) + `((prev-buffers + . ,(if writable + (mapcar (lambda (entry) + (list (buffer-name (nth 0 entry)) + (marker-position (nth 1 entry)) + (marker-position (nth 2 entry)))) + prev-buffers) + prev-buffers)))))) (tail (when (memq type '(vc hc)) (let (list) --=-=-=--