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'. But maybe this could be customizable? Tried to write an advice: (advice-add 'delete-window :around (lambda (orig-fun &optional window) (if window ;; Non-interactive call (funcall orig-fun window) ;; Interactive call (let* ((pos (window-absolute-pixel-position)) (x (when pos (/ (car pos) (frame-char-width)))) (y (when pos (/ (cdr pos) (frame-char-height))))) (funcall orig-fun window) ;; Select window that takes space from the deleted window (when (and x y) (select-window (window-at x y)))))) '((name . delete-window-keep-pos))) Maybe something like this could be adapted to delete-window by adding an optional interactive argument keep-pos: