Subject: Re: bug#33871: 27.0.50; Revert Dired window saved in window configuration

From: Juri Linkov <[email-masked]>
Date: Sun, 30 Dec 2018 01:21:05 +0200

>> So the revert function doesn't use markers?  Maybe then
>> set-window-configuration should not use markers too?
>
> 'dired-revert' is special.  There's nothing we can conclude from it.

image-revert is another special, as indicated by bug#33631

>>>> Here is when the upper window is selected, but still it moves to (point-max)
>>>> in non-selected window:
>>>>
>>>> (progn (dired "/tmp")
>>>>          (dired-other-window "/tmp") (other-window 1)
>>>>          (let ((w-c (current-window-configuration))
>>>> 	     (p-m (point-marker)))
>>>> 	 (view-emacs-todo) (delete-other-windows)
>>>> 	 (with-current-buffer (get-buffer "tmp")
>>>> 	   (revert-buffer))
>>>> 	 (set-window-configuration w-c)))
>>>
>>> In every non-selected window.  Try with as many windows as you want.
>>> Only the selected window is handled separately.
>>
>> A bug?

Do you know why it currently moves point to the end of the buffer
in non-selected windows.  I don't understand what causes this behavior.

> As I suggested earlier we can use the position of the buffer's point
> in every window regardless of whether it currently shows the buffer or
> we later switch to the buffer in it.  But this is not what we usually
> want when using multiple windows: We usually want them to show
> different portions of the same buffer.

Yes, better to keep every window's own point.  Since usually I save
the selected window's point along with the window configuration, in e.g.

((window-configuration-1 selected-window-point)
 (window-configuration-2 selected-window-point)
 ...)

this could be extended to save a mapping of all windows points, e.g.

((window-configuration-1 ((window-a point-a) (window-b point-b) ...))
 (window-configuration-2 ...)
 ...)

But it's not a general solution.  A general solution would be to save
such metadata in the window configuration itself.