title: [emacs][gdb customization] How to display source-buffer in one window?
body: <p>I have customized gdb windows in emacs. After it during debugging new source code opens in different windows. I'd like to see source code only in one window. My gdb customization is:</p>
  
  <pre><code>;     _____________________________________________________________________________________
  ;    |                                          |                                          |
  ;    |              BREAKPOINTS                 |                                          |
  ;    |__________________________________________|                                          |
  ;    |                                          |                                          |
  ;    |                 STACK                    |                                          |
  ;    |__________________________________________|                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                 LOCALS                   |                                          |
  ;    |                                          |                SOURCE CODE               |
  ;    |__________________________________________|                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                  GDB                     |                                          |
  ;    |                                          |__________________________________________|
  ;    |                                          |                                          |
  ;    |                                          |                                          |
  ;    |                                          |                    I/O                   |
  ;    |                                          |                                          |
  ;    |__________________________________________|__________________________________________|
  
  (require 'gud)
  
  ; invoke
  (global-set-key [f8] 'gdb)
  
  ; GDB layout
  (defadvice gdb-setup-windows (after activate)
    (gdb-setup-my-windows)
  )
  
  (defun gdb-setup-my-windows ()
    (set-window-dedicated-p (selected-window) nil)
    (switch-to-buffer gud-comint-buffer)
    (delete-other-windows)
    (let
      ((win0 (selected-window))             ; breakpoints
       (win1 (split-window-horizontally
           (floor (* 0.5 (window-width)))))   ; source + i/o
       (win2 (split-window-vertically
           (floor (* 0.5 (window-body-height))))) ; gdb
       (win3 (split-window-vertically
          (floor (* 0.5 (window-body-height))))) ; locals
       (win4 (split-window-vertically
           (floor (* 0.6 (window-body-height))))) ; stack
      )
      (select-window win1)
      ; configurating right window
      (let
      ((winSrc (selected-window)) ; source
       (winIO (split-window-vertically (floor (* 0.9 (window-body-height))))) ; I/O
       )
        (set-window-buffer winIO (gdb-get-buffer-create 'gdb-inferior-io))
        (set-window-buffer
      winSrc
      (if gud-last-last-frame
       (gud-find-file (car gud-last-last-frame))
        (if gdb-main-file
         (gud-find-file gdb-main-file)
       (list-buffers-noselect))))
        (setq gdb-source-window winSrc)
        (set-window-dedicated-p winIO t)
     )
  
      (set-window-buffer win0 (gdb-get-buffer-create 'gdb-breakpoints-buffer))
      (set-window-buffer win3 (gdb-get-buffer-create 'gdb-locals-buffer))
      (set-window-buffer win4 (gdb-get-buffer-create 'gdb-stack-buffer))
      (select-window win2)
    )
  )
  
  ; GDB variables
  (setq gdb-many-windows t)
  (setq gdb-show-main t)
  (setq gdb-show-changed-values t)
  (setq gdb-use-colon-colon-notation t)
  (setq gdb-use-separate-io-buffer nil)
  (setq gdb-delete-out-of-scope t)
  (setq gdb-speedbar-auto-raise t)
  </code></pre>
  
  <p>The main screen is:
  <a href="http://i.stack.imgur.com/iHZLZ.png" rel="nofollow">gdb screen after start</a></p>
  
  <p>But when I started debugging then next source file opens in another window. See example bellow:
  <a href="http://i.stack.imgur.com/4G0Hy.png" rel="nofollow">New source code  in gdb window</a></p>
  
  <p>The example of application to reproduce is:</p>
  
  <p><em>main.cpp</em></p>
  
  <pre><code>#include "classB.h"
  
  int main()
  {
    B *b = 0;
    b = new B();
    return 0;
  }
  </code></pre>
  
  <p><em>classA.h</em></p>
  
  <pre><code>#ifndef CLASS_A_H
  #define CLASS_A_H
  
  class A
  {
  public:
    A();
  };
  
  #endif
  </code></pre>
  
  <p><em>classA.cpp</em></p>
  
  <pre><code>#include "classA.h"
  #include &lt;iostream&gt;
  
  A::A()
  {
    std::cout &lt;&lt; "Constructor A" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p><em>classB.h</em></p>
  
  <pre><code>#ifndef CLASS_B_H
  #define CLASS_B_H
  
  #include "classA.h"
  
  class B : public A
  {
  public:
    B();
  };
  
  #endif
  </code></pre>
  
  <p><em>classB.cpp</em></p>
  
  <pre><code>#include "classB.h"
  #include &lt;iostream&gt;
  
  B::B() : A()
  {
    std::cout &lt;&lt; "Constructor B" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p><em>Makefile</em></p>
  
  <pre><code>SOURCES=main.cpp classA.cpp classB.cpp
  TARGET=test
  CXX_FLAGS=-g
  
  .PHONY: all
  
  all: $(TARGET)
  
  $(TARGET): $(SOURCES)
      $(CXX) $(CXX_FLAGS) $^ -o $@
  
  .PHONY: clean
  
  clean:
      rm -vf $(TARGET)
  </code></pre>
  
  <p>Step to reproduce:</p>
  
  <ol>
  <li><p>Run emacs</p></li>
  <li><p>M-x gdb</p></li>
  <li><p>gdb -i=mi test</p></li>
  <li><p>In gdb command window run: start</p></li>
  <li><p>run: next</p></li>
  <li><p>run: step</p></li>
  </ol>
  
  <p>My environment is: Ubuntu14.04, gdb - 7.7.1, emacs - 25.1.1.</p>
  
  <p>I tried to use <strong><em>set-window-dedicated-p</em></strong>. But this is not solution for my problem.
  I'm new in emacs, help me please, what is wrong in my configuration?</p>