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

From: Juri Linkov <[email-masked]>
Date: Sun, 30 Dec 2018 23:29:30 +0200

>> image-revert is another special, as indicated by bug#33631
>
> But there the position of point or that of its window has no impact, I
> presume.

Yes, but there image-revert needs to know window dimensions
when the buffer is not displayed in a window - a situation
similar to dired-revert when buffer's windows are in a window
configuration.

>> 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.
>
> I nowlooked into it.  It's a bug caused by
>
> 	  XMARKER (p->pointm)->insertion_type
> 	    = !NILP (buffer_local_value /* Don't signal error if void.  */
> 		     (Qwindow_point_insertion_type, w->contents));
>
> and the value of
>
> buffer_local_value (Qwindow_point_insertion_type, w->contents)
>
> is unbound and not nil.  I have to fix that.

> I tried to fix that on master now.  Please have a look.

Thanks, I confirm it's fixed.

>>> 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,
>
> As number or as marker?

As marker.  But I guess due to marker invalidation after reverting
better to use numbers, or even better to get metadata depending
on major mode, e.g. in case of Dired - dired-filename.

>> 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.
>
> But a configuration saves the point of each window, for the selected
> one it stores the point of that window's buffer.  Is it just because
> you want to be able to retrieve those values?  Or what am I missing?

It seems a configuration saves the point as marker, not as number, so it
invalidates on reverting.  It would be better if such stored metadata also
includes dired-filenames, or even a lambda that could move point to saved
filenames in Dired buffers.

((window-configuration-1 ((dired-window-1 . `(lambda () (dired-goto-file ,(dired-get-filename))))))
 (window-configuration-2 ...)
 ...)