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

From: Juri Linkov <[email-masked]>
Date: Fri, 04 Jun 2021 00:20:32 +0300

> I called them just 'mru' and 'pos' now.  The option is called
> `selected-window-after-deletion', there might be better names.

Maybe better with the same name prefix as `delete-window'?
For example, `delete-window-select'?  But the current is also fine.

> Please have a look.

Thanks, I tested out, and everything works nicely.
Only minor remarks:

> +(defun get-mru-window (&optional all-frames dedicated not-selected no-other)
> +non-nil means never return the selected window.  Optional
> +argument NO_OTHER non-nil means to never return a window whose

Typo:       NO-OTHER

> +(defcustom selected-window-after-deletion 'mru

Not strictly necessary now, but for future extensions
would it be possible to allow this option
to be customized to a function that selects a window?

> +  :type '(choice (const :tag "Most recently used" mru)
> +                 (const :tag "At position" pos)
> +                 nil)

This 'nil' needs to be replaced with a list like:

                    (const :tag "First window" nil)

> +        ;; If we deleted the selected window of WINDOW's frame, choose
> +        ;; another one based on `selected-window-after-deletion'.  Note
> +        ;; that both `window-at-pos' and `get-mru-window' mail fail to
                                                             =========
Typo.