title: How to start emacs with ipython shell running in one side of a divided window?
body: <p>I´d like to have the following workflow using emacs 23.4 as a python (2.7) IDE on Debian:</p>
  
  <ol>
  <li>Emacs initiates with 2 windows side-by-side when opening a file like $ emacs file.py</li>
  <li>There´s already a shell in the left window and the buffer file.py in the right window.</li>
  <li>A shortcut executes the code (and another shortcut for parts of it) and the result can be seen in the left window (ipython shell). The focus remains at the right window and the buffers don´t change when the command is executed.</li>
  <li>A shortcut easily switches the focus from left to right and the other way around.</li>
  </ol>
  
  <p>I could, so far, accomplish everything except the second item (I have to make the buffer visible manually), which seems simple. I´ve been reading the emacs lips reference manual, so that I can customize emacs myself, but I´m still a beginner in emacs. I also found some similar questions, but not fully helpful. Here are some relevant parts of my .emacs.</p>
  
  <pre><code>;; Initial frame size and position (1280x1024)
  (setq default-frame-alist
    '((top . 45) (left . 45)
      (width . 142) (height . 54)))
  (if (window-system) 
    (split-window-horizontally (floor (* 0.49 (window-width))))
  )
  
  ; python-mode
  (setq py-install-directory "~/.emacs.d/python-mode.el-6.1.3")
  (add-to-list 'load-path py-install-directory)
  (require 'python-mode)
  
  ; use IPython
  (setq-default py-shell-name "ipython")
  (setq-default py-which-bufname "IPython")
  ; use the wx backend, for both mayavi and matplotlib
  (setq py-python-command-args
    '("--gui=wx" "--pylab=wx" "--colors=linux"))
  (setq py-force-py-shell-name-p t)
  
  ; switch to the interpreter after executing code
  (setq py-shell-switch-buffers-on-execute-p t)
   ;(setq py-switch-buffers-on-execute-p t)
  
  ; don't split windows
  (setq py-split-windows-on-execute-p nil)
  ; try to automagically figure out indentation
  (setq py-smart-indentation t)
  
  (defun goto-python-shell () 
    "Go to the python command window (start it if needed)" 
    (interactive)
    (setq current-python-script-buffer (current-buffer))
    (py-shell)
    (end-of-buffer)
  )
  (goto-python-shell)
  </code></pre>
  
  <p>I believe the solution is simple and lies on the functions/variables: switch-to-buffer, initial-buffer-choice, other-window, py-shell-switch-buffers-on-execute-p, py-switch-buffers-on-execute-p. </p>
  
  <p>However, I still couldn't find a solution that makes it all work.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I was able to have my desired behavior, substituting the last part for:</p>
  
  <pre><code>(switch-to-buffer (py-shell))
  (end-of-buffer)
  (other-window 3)
  (switch-to-buffer (current-buffer))
  </code></pre>
  
  <p>, since I found out with get-buffer-window that the left window appears as 3 and right window as 6.</p>