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

From: Juri Linkov <[email-masked]>
Date: Thu, 21 Mar 2024 19:54:51 +0200

>> Avoiding select-window removed simplicity and now requires
>> adding more handling and more testing.  But finally
>> everything works correctly.  Please review the new patch:
>
> Can you please provide me with a complete scenario the old code got
> wrong?  I'm rather confused by the number of different bugs we've been
> trying to solve here.

There are two scenarios that this patch will fix:

1. switching tabs with the same reverted Dired buffer

For example,

a. create two windows with the same Dired buffer (e.g. split-window)
b. clone the tab with 'C-x t n'
c. revert Dired buffer with 'g'
d. switch back to the previous tab
e. observe that point in the non-selected Dired window
   relocates to the top of the buffer
f. in Emacs 30 point is relocated also in the selected window

2. second scenario for file buffers:

a. visit a file buffer
b. clone the tab with 'C-x t n'
c. edit the same file buffer before the previous point
d. save the desktop (that turns markers into integers)
e. restart Emacs and load the desktop
f. optionally edit the same buffer again
g. switch back to the previous tab
h. due to integer positions point is restored in a random place

The patch uses the context functions to restore the right position.

> IIUC the original Bug#33871 is still unsolved.

The proposed patch will close bug#33871.

> Bug#33532 as well.

Bug#33532 could be closed as well due to new context functions.

> What about Bug#68235 and Bug#69093?

Bug#68235 is closed, but the patch will solve the issue
mentioned in https://debbugs.gnu.org/68235#79
starting with the words:
"BTW, there is another problem when the same buffer is displayed
in two tabs/window-configurations."

Bug#69093 is completely fixed.

> And Bug#12253?

Bug#12253 is unrelated, but thanks for reminder,
it should be addressed later as well.