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

From: martin rudalics <[email-masked]>
Date: Thu, 24 Feb 2022 10:19:17 +0100

> But window states don't contain pointers to windows.
 > So it's impossible to find e.g. '(selected-window)'
 > in a window state returned by '(window-state-get)'.

But you can easily write a function to inspect a window state.

 > Then we could save additional context information the same way as
 > currently this special exceptional value of point is saved, e.g.
 > in 'tab-bar--tab':
 >
 >        (wc . ,(current-window-configuration))
 >        (wc-point . ,(point-marker))
 >
 > where 'point-marker' is saved separately from 'current-window-configuration'.
 > And then it's restored in 'tab-bar-select-tab':
 >
 >              ;; set-window-configuration does not restore the value of
 >              ;; point in the current buffer, so restore it separately.
 >              (when (and (markerp wc-point)
 >                         (marker-buffer wc-point)
 >                         ;; FIXME: After dired-revert, marker relocates to 1.
 >                         ;; window-configuration restores point to global point
 >                         ;; in this dired buffer, not to its window point,
 >                         ;; but this is slightly better than 1.
 >                         ;; Maybe better to save dired-filename in each window?
 >                         (not (eq 1 (marker-position wc-point))))
 >                (goto-char wc-point))
 >
 > Please note that this bug report is related to FIXME above.
 >
 > So a possible solution is also to save more context information
 > like dired-filename, and then restore it using dired-goto-file.

We obviously then should strive for a solution that stores any kind of
information via a hook in an alist of entries, one for each window in a
buffer local way, and one global entry for the frame itself.

martin