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

From: martin rudalics <[email-masked]>
Date: Sun, 28 Oct 2018 10:00:37 +0100

> But window-state-put has such deficiency with its undocumented
 > prerequisite that a new unique window should be created manually
 > before calling window-state-put to put the state into a new
 > window (to not share it with other window configurations).

Maybe "to not share it with other frames" would be more precise.  What
you probably want is a facility to clone a window.  I have no idea how
to do that and which semantics to attach to a cloned window.  Always
keep in mind: Windows that have been deleted but go on "living" in
stored configurations are zombies.  And dealing with the undead can be
cumbersome ...

 > This means a need in such ugly hack:
 >
 > ;; Create a new window
 > (delete-other-windows) (split-window) (delete-window)
 > ;; Put a previous state into the new window
 > ;; to not share it with other window configurations
 > (window-state-put previously-saved-window-state nil 'safe)
 > ;; Get its window configuration
 > (current-window-configuration)
 >
 > Please confirm is `(delete-other-windows) (split-window) (delete-window)'
 > is the right idiom to create a new window to put the window state into,
 > or there is a special function to create a window, that I can't find.

You can put a window state into any valid window, usually the frame's
root window.  Just that under the hood 'window-state-put' will do the
'delete-other-windows' then.

 > The code above does the opposite, but it requires an ugly workaround
 > for window-state-put.

Please elaborate.  In which sense does that code make a configuration
from a state?

 > Like the earlier code snippet demonstrates it causes problems when
 > the same window appears an arbitrary number of times in stored window
 > configurations.  Thus the need to create a new window to put the state into
 > (currently window-state-put itself doesn't create a new unique window).

I lost you.  Anything Lisp code can do is create a new unique window.
Lisp code cannot create a new non-unique window.

martin