Subject: bug#32850: 27.0.50; window-swap-states doesn't swap window prev/next-buffers

From: martin rudalics <[email-masked]>
Date: Wed, 17 Oct 2018 09:31:37 +0200

> 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.

 > 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.

So yes: Please use a buffer object for non-writable states.

martin