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

From: Michael Welsh Duggan <[email-masked]>
Date: Sun, 23 Nov 2014 18:27:47 -0500

martin rudalics <[email-masked]> writes:

>>>  Where is this `switch-to-buffer' call issued?
>>
>> In `gud-common-init'.
>
> Thanks, I haven't looked into that code for years.  And the final
> `display-buffer' call that causes trouble is in `gud-display-line'?
>
> In that case how about the following: In `gud-common-init' instead of
> `switch-to-buffer' let's call `display-buffer' with an action list that
> would go like
>
>   (display-buffer-reuse-window display-buffer-in-previous-window
>    display-buffer-same-window display-buffer-pop-up-window)
> 		
> and in `gud-display-line' use `inhibit-same-window' as you proposed
> earlier (and maybe `inhibit-switch-frame' as well).  WDYT?  Could you
> try writing an according patch for gud.el?

Sorry this took so long.  I've done minimal testing so far, and will
have to test some more under real debugging situations, but the
included patch does alleviate at least one problem I am having.

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 24d5469..82846eb 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2603,6 +2603,10 @@ comint mode, which see."
 		      file-subst)))
 	 (filepart (and file-word (concat "-" (file-name-nondirectory file))))
 	 (existing-buffer (get-buffer (concat "*gud" filepart "*"))))
+    (select-window
+      (display-buffer
+       (get-buffer-create (concat "*gud" filepart "*"))
+       '(display-buffer-reuse-window display-buffer-in-previous-window)))
     (switch-to-buffer (concat "*gud" filepart "*"))
     (when (and existing-buffer (get-buffer-process existing-buffer))
       (error "This program is already being debugged"))

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