unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 32850@debbugs.gnu.org
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	[thread overview]
Message-ID: <87zhvcteuy.fsf@mail.linkov.net> (raw)
In-Reply-To: <5BC6E559.3090000@gmx.at> (martin rudalics's message of "Wed, 17 Oct 2018 09:31:37 +0200")

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]

>> 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 #<killed buffer> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: window-state-prev-next-buffers.2.patch --]
[-- Type: text/x-diff, Size: 2161 bytes --]

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)

  reply	other threads:[~2018-10-17 21:58 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 23:39 bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers Juri Linkov
2018-09-27 18:45 ` martin rudalics
2018-09-27 22:52   ` Juri Linkov
2018-09-30  8:00     ` martin rudalics
2018-09-30 20:00       ` Juri Linkov
2018-10-01  8:35         ` martin rudalics
2018-10-08 22:41           ` Juri Linkov
2018-10-09  7:44             ` martin rudalics
2018-10-15 20:48               ` Juri Linkov
2018-10-16  8:45                 ` martin rudalics
2018-10-16 22:37                   ` Juri Linkov
2018-10-17  7:31                     ` martin rudalics
2018-10-17 21:58                       ` Juri Linkov [this message]
2018-10-18  8:05                         ` martin rudalics
2018-10-18 22:37                           ` Juri Linkov
2018-10-19  7:40                             ` martin rudalics
2018-10-20 21:40                               ` Juri Linkov
2018-10-21  8:22                                 ` martin rudalics
2018-10-21 18:14                                   ` Juri Linkov
2018-10-22  9:07                                     ` martin rudalics
2018-10-23 20:45                                       ` Juri Linkov
2018-10-24  9:45                                         ` martin rudalics
2018-10-24 23:39                                           ` Juri Linkov
2018-10-25  6:04                                             ` martin rudalics
2018-10-25 19:19                                               ` Juri Linkov
2018-10-26  7:39                                                 ` martin rudalics
2018-10-26  7:59                                                   ` Eli Zaretskii
2018-10-27 20:09                                                   ` Juri Linkov
2018-10-28  9:00                                                     ` martin rudalics
2018-10-28 19:29                                                       ` Juri Linkov
2018-10-29  8:44                                                         ` martin rudalics
2018-10-29 22:45                                                           ` Juri Linkov
2018-10-30  9:00                                                             ` martin rudalics
2018-10-30 21:23                                                               ` Juri Linkov
2018-10-31  8:11                                                                 ` martin rudalics
2018-10-31 21:25                                                                   ` Juri Linkov
2018-11-01  9:03                                                                     ` martin rudalics
2018-11-01 22:30                                                                       ` Juri Linkov
2018-11-02  8:43                                                                         ` martin rudalics
2018-11-05 21:38                                                                           ` Juri Linkov
2018-11-06  3:26                                                                             ` Eli Zaretskii
2018-11-06 22:35                                                                               ` Juri Linkov
2018-11-06  8:46                                                                             ` martin rudalics
2018-11-10 21:56                                                   ` Juri Linkov
2018-11-11  8:53                                                     ` martin rudalics
2018-11-11 20:23                                                       ` Juri Linkov
2018-11-12  8:53                                                         ` martin rudalics
2018-11-12 23:47                                                           ` Juri Linkov
2018-11-13  9:09                                                             ` martin rudalics
2018-11-13 23:43                                                               ` Juri Linkov
2018-11-14  8:34                                                                 ` martin rudalics
2018-11-15  0:02                                                                   ` Juri Linkov
2018-11-15  9:12                                                                     ` martin rudalics
2018-11-15 21:30                                                                       ` Juri Linkov
2018-11-16  8:52                                                                         ` martin rudalics
2018-11-17 22:04                                                                           ` Juri Linkov
2018-11-18  9:23                                                                             ` martin rudalics
2018-11-17 17:01                                                                         ` Charles A. Roelli
2018-11-17 22:01                                                                           ` Juri Linkov
2018-11-18  9:23                                                                             ` martin rudalics
2018-11-18 22:47                                                                               ` Juri Linkov
2018-11-19  9:42                                                                                 ` martin rudalics
2018-11-19 22:28                                                                                   ` Juri Linkov
2018-11-20  9:27                                                                                     ` martin rudalics
2018-11-21  0:08                                                                                       ` Juri Linkov
2018-11-21  8:20                                                                                         ` martin rudalics
2018-11-21 23:44                                                                                           ` Juri Linkov
2018-11-22  7:41                                                                                             ` martin rudalics
2018-11-15  9:23                                                                     ` martin rudalics
2018-10-18 23:18                   ` Juri Linkov
2018-10-19  7:40                     ` martin rudalics
2018-10-25 19:31                       ` Juri Linkov
2018-10-26  7:41                         ` martin rudalics
2018-10-27 21:11                           ` Juri Linkov
2018-10-27 21:39                           ` Juri Linkov
2018-10-28  9:01                             ` martin rudalics
2018-10-28 19:09                               ` Juri Linkov
2018-10-29  8:43                                 ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhvcteuy.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=32850@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).