Subject: Re: bug#33458: 27.0.50; dired loses position when reverted from outside place

From: Juri Linkov <[email-masked]>
Date: Tue, 25 Dec 2018 23:25:41 +0200

>> Thanks, but I expected it to be more configurable, i.e. to also look
>> at prev/next-buffers in a saved configuration when needed, etc.
>
> We can easily do that.  But note that a window's previous and next
> buffers are stored in the window itself (where, if the window is live,
> they can change at any time) and not in the window copy stored in the
> configuration.

Oh, I see now why this case fails:

(let ((_ (view-emacs-todo))
      (w-c (current-window-configuration)))
  (view-emacs-news)
  (set-window-configuration w-c)
  (previous-buffer))

I expected it not to change prev/next buffers of the window
saved in the window configuration, so the expectation for the
last call to 'previous-buffer' was to return from the TODO buffer
to the original buffer *scratch*.  But since the NEWS buffer
meddled with the same window, this is not the case.

This is why any code that saves window configurations has to care
about creating a new window after the current-window-configuration
call (thus removing the window saved in the window configuration),
like I fixed now in https://gitlab.com/link0ff/emacs-wincows/commit/226cf229

>> This could be achieved with a complete export of the saved
>> configuration to a Lisp structure.
>
> It's a bit tedious to code but can be certainly done.  But I suppose
> that what might then interest you just as well is to transform window
> states into window configurations ;-)

Indeed, this would simplify many things.