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

From: martin rudalics <[email-masked]>
Date: Fri, 4 Jun 2021 11:19:29 +0200

>> 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.

It's not about "selecting a window", it's about "setting a frame's
selected window".

 >> +(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

Indeed.

 >> +(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)

In general, just plugging in some existing function would usually fail
here and I would like to avoid the illusion that it could work.  Also,
as you can see with the 'pos' case, some work must be done _before_
calling `delete-window-internal' so the actual work would have to be
split among two functions at least.

 > 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.

But it rhymes!

martin