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

From: martin rudalics <[email-masked]>
Date: Thu, 17 Feb 2022 11:05:56 +0100

> Instead of (goto-char p-m), after (set-window-configuration w-c)
 > something like this should be performed:
 >
 >    (dired-goto-file (car (cdr (assoc (current-buffer)
 >                                      (window-parameter nil 'dired-positions)))))

Once more: Your scenario is

(progn (dired "/tmp") (dired-next-line 1)
        (split-window) (other-window 1)
        (dired "/tmp") (dired-next-line 2)
        (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)
	 (goto-char p-m)))

But this cannot work with dired buffers because they are reverted in a
special way that does not care about 'window-point' and the like.  This
means that the value of 'point-marker' you saved in p-m has become just
meaningless after the 'revert-buffer' call.

Basically, this is a hard problem we'll probably never be able to solve
satisfactorily.

We could handle 'window-point' separately when saving and restoring
window configurations and the window's buffer is a dired buffer.  For
example, 'dired-revert' could call a function 'window-revert-timestamp'
to store the current time of the revert operation for this window and
'current-window-configuration' (and 'window-state-get') would store
their current time stamp in the configuration (or state).  Then
'set-window-configuration' (and 'window-state-put') could check whether
a window's revert time stamp is larger than the time stamp stored in the
configuration and not set point for that window when the revert time
stamp is later.  Is it worth the hassle?

martin