Subject: Re: bug#77946: master d283db57733: Fix window selection after log-edit-show-diff, again

From: Juri Linkov <[email-masked]>
Date: Mon, 21 Apr 2025 09:28:11 +0300

>>> > diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
>>> > index 0da0b90975c..3c3288777c8 100644
>>> > --- a/lisp/vc/log-edit.el
>>> > +++ b/lisp/vc/log-edit.el
>>> > @@ -857,7 +857,8 @@ vc-log-fileset
>>> >  (defun log-edit-diff-fileset ()
>>> >    "Display diffs for the files to be committed."
>>> >    (interactive)
>>> > -  (vc-diff nil nil (list log-edit-vc-backend vc-log-fileset)))
>>> > +  (save-selected-window
>>> > +    (vc-diff nil nil (list log-edit-vc-backend vc-log-fileset))))
>>>
>>> This change broke the command 'log-edit-show-diff' ('C-c C-d').
>>> Previously it selected the diff window.  Now it always stays in the vc-log window.
>>
>> Isn't it a bug in log-edit-show-diff?  Why does it assume that it will
>> be put in the diff window?  It should instead switch there.
>
> Yes, I think you're basically right, but I think we should have two
> things:
>
> - a command, bound to C-c C-d, that both displays and selects the window
> - a function, an option for log-edit-hook, that only displays the window
>
> So the changes required are:
>
> - write a new command that both dispalys and selects the window, bind it
>   to C-c C-d
>
> - add log-edit-show-diff to the customisation options for log-edit-hook.

Please note that the decision whether to select the window
can be customized by the users with 'post-command-select-window'
in 'display-buffer-alist'.  So preferably the commands should just
call the plain 'display-buffer' or 'pop-to-buffer'.  I suppose
for the required changes above you meant using 'pop-to-buffer'
for the first and 'display-buffer' for the second.