Subject: bug#17675: 24.4.50; *gud* buffer keeps on getting buried

From: Michael Welsh Duggan <[email-masked]>
Date: Sun, 20 May 2018 20:18:06 -0400

Noam Postavsky <[email-masked]> writes:

> Michael Welsh Duggan <[email-masked]> writes:
>
>> And one more time, this time incorporating your suggestion more
>> completely.
>>
>> diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
>> index 24d5469..71dc574 100644
>> --- a/lisp/progmodes/gud.el
>> +++ b/lisp/progmodes/gud.el
>> @@ -2603,7 +2603,12 @@ comint mode, which see."
>>  		      file-subst)))
>>  	 (filepart (and file-word (concat "-" (file-name-nondirectory file))))
>>  	 (existing-buffer (get-buffer (concat "*gud" filepart "*"))))
>> -    (switch-to-buffer (concat "*gud" filepart "*"))
>> +    (select-window
>
> Is this select-window call neeeded?

I think so, since `display-buffer' does not necessarily select the window
in which it displays the buffer, whereas the `switch-to-buffer' it is
replacing displays the buffer in the currently selected window.
Certainly in this case you want the "*gud*" buffer to be the selected
buffer after this command.

This bug was actually "fixed" using my original suggestion of binding
`inhibit-same-window' to t, but I am not qualified to say which solution
is "more correct."  See
<URL:http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=fd93edbb1cabfdf0c732dbb0c6892a515b406a65>.

>> +      (display-buffer
>> +       (get-buffer-create (concat "*gud" filepart "*"))
>> +       '(display-buffer-reuse-window 
>> +         display-buffer-in-previous-window
>> +         display-buffer-same-window display-buffer-pop-up-window)))
>>      (when (and existing-buffer (get-buffer-process existing-buffer))
>>        (error "This program is already being debugged"))
>>      ;; Set the dir, in case the buffer already existed with a different dir.
>
> Martin, I see the switch-to-buffer is still present in master now,
> should it be fixed?

-- 
Michael Welsh Duggan
([email-masked])