Subject: Re: bug#33258: inhibit-select-window

From: Juri Linkov <[email-masked]>
Date: Mon, 05 Nov 2018 23:30:33 +0200

>> One of the many examples is 'C-x v =' (vc-diff) where
>> the need is only to look at the diffs, but not to operate
>> on the *vc-diff* buffer in its window.
>
> Is this particular behavior caused by the
>
>       ;; Display the buffer, but at the end because it can change point.
>       (pop-to-buffer (current-buffer))

Yes, and rightfully so.

> While not selecting the window might not be a great issue, not making
> its buffer current is.  We would have to check each and every call of
> 'pop-to-buffer' as to whether subsequent code relies on the fact that
> it made the buffer current.  This is not fathomable IMO.

This feature is intended only for user customization in display-buffer-alist,
not in the args of pop-to-buffer.  It makes no sense for a programmer
to use (inhibit-select-window . t) in the args of pop-to-buffer when
a programmer can simply replace pop-to-buffer with a display-buffer call.

However, if an user is annoyed by always selecting a window of
a displayed buffer by default, and such customization doesn't
cause a bad side effect by not making the displayed buffer the current,
and this is true in 99% cases, then we should be proud to make
the users happier.

>> OTOH, when a command uses display-buffer that doesn't select a window,
>> then the same alist entry with a different value or a new entry e.g.
>> '(select-window . t)' could be used to force selecting the window.
>> This could be implemented by using the same code from pop-to-buffer
>> and adding it to display-buffer functions.
>
> This would be possible.  Such an entry would have to be called
> something like 'force-select-window' and could be applied by both
> users and programs for one soberingly simple reason: A Lisp program
> can never rely upon 'display-buffer' to _not_ select the chosen window
> - popping up a new frame may implicitly select the window at any time.

force-select-window looks good, also possible is one of these names:

  (pop-to-buffer . t)
or
  (pop-up-window . t)

as a reference to the related feature.