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

From: Juri Linkov <[email-masked]>
Date: Tue, 18 Dec 2018 02:25:57 +0200

>>> Imagine a scenario where a user (1) displays a buffer in new window,
>>> (2) switches in that window to another buffer and (3) deletes that
>>> window for good.  When and how would the buffer-local reference
>>> created in (2) be removed?
>>
>> Another question: When should the buffer-local reference be added?
>>
>> Every time when point is moved to a new file?  Too frequent calls especially
>> in cases of e.g. pressing and holding the spacebar to move thru the file list.
>>
>> Or when current-window-configuration is saved to a variable/register
>> or window-state-get is called?  I don't know what hook is possible
>> to use at that moment besides advices.
>
> I'm not sure whether my scenario above was entirely clear.  The
> "buffer-local reference" I was talking about would be a buffer-local
> list whose cars are all the windows (including dead ones) that showed
> the buffer before.  When reverting a buffer, we would traverse that
> list, and for every window in that list (including dead windows) look
> up the buffer reference in that window's previous buffers, calculate
> the new window point position from the old position and store back the
> new position as marker in situ there.

Is it really possible to get a window from the window-configuration
that is currently not displayed and change its window-point, e.g.
to get window reference from the buffer-local list, select with
with-selected-window and call set-window-point?  I never tried such thing.

> So the answer to your question "When should the buffer-local reference
> be added?" is the earlier alluded to "in (2) when we unshow that
> buffer in a window".  And the problem we have to solve is when to
> remove such a reference because the referenced window is really dead
> and no more referenced by any saved window configuration.

It's clear from you explanation what harm is from zombie windows.
But it's interesting to know is it possible to catch the moment
when we unshow that buffer in a window?