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

From: Juri Linkov <[email-masked]>
Date: Fri, 19 Oct 2018 01:37:11 +0300

>> 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?
>
> 'kill-buffer' calls 'replace-buffer-in-windows' which, if the window
> doesn't show the buffer, calls 'unrecord-window-buffer' which removes
> the buffer from the respective lists.  But 'replace-buffer-in-windows'
> handles only live windows, it can't look into window configurations.

If we had a function that can look into window states, then a user
could put it on kill-buffer-hook to look into window states stored
in user variables.  It would be useful to have a function to check if
a buffer exists in window state: often there is a need not to kill
a buffer if it's stored in some window state variable (so restoring
a saved window state will always show the same buffers as before).

>> 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.
>
> It would be interesting to have such a thing.  One could use it to
> handle conversion of non-writable objects to writable ones (I always
> wondered how desktop would handle non-writable values in say
> 'dedicated' or a window parameter) and back.  But we don't yet have a
> sufficiently reliable mechanism for providing a serializable value for
> a number of our objects - in particular windows and frames.

A serializable value of window objects are window states.  By analogy with
the eq/equal dichotomy, window objects can be compared with ‘eq’, and
window states with ‘equal’.