Subject: Re: bug#47300: delete-window to select window with same position

From: martin rudalics <[email-masked]>
Date: Tue, 18 May 2021 18:00:40 +0200

>> People still have trouble with unpredictable behavior of 'C-x 0'
 >> that selects an unexpected window after the current window is deleted.
 >>
 >> This is a recent example:
 >> https://old.reddit.com/r/emacs/comments/m8omt0/how_can_deletewindow_cx_0_be_configured_to_stay/
 >>
 >> The previous failed attempt to fix this was in bug#32790.
 >>
 >> I still don't understand the current logic what window is selected
 >> after deleting the selected window with 'C-x 0'.

By design it's the most recently used window (`get-mru-window') on the
same frame after the deleted window has been removed from its window
tree.

 > `C-x 0' isn't a command I use much, so I don't really have much
 > intuition about how it's supposed to work.  But, indeed, playing around
 > with it, it seems unexpected that `C-x 0' selects a different window
 > (instead of remaining in the "merged" window).
 >
 >> Maybe something like this could be adapted to delete-window
 >> by adding an optional interactive argument keep-pos:
 >
 > If I'm reading that patch correctly (I haven't actually tested), that
 > seems more DWIM to me.  Perhaps Martin has some comments here; added to
 > the CCs.  (And if anybody else has an opinion here, please do chime in.)

Personally I don't care but people used to the current behavior might
get confused.  So an option should be the provided and could be "ON" by
default.

martin