Hello. Let's suppose that I am editing a .py file with py code. I decide to run the code that I wrote. I can do so by various means: I can chose to execute the entire buffer by running py-execute-buffer or by selecting a region and and doing py-execute-region **** What happens now: py-execute-buffer: if the same frame contains a *Python* interpeter window in position strictly adjacent to the window with the source code the code is executed there and the focus is switched back to the window containing the source code. If there is no window containing the *Python* buffer among the windows stricty adjacent to the source code window a new window is created (if there were none) or an existing adjacent window is used to display the *Python* buffer. If there were, for whatever reason, more than one window with the source code buffer opened then the focus may be restored to the "wrong" window, i.e. not the one from which the py-execute-buffer was called. py-execute-region: the same thing happens as with py-execute-buffer but the focus is never returned to the source code buffer window. This is particularly frustrating in my case This happens independently of what py-shell-switch-buffers-on-execute is set to (nil or t) This behavior was observed in SYNC mode with the *Python* buffer and not the *Python Output* buffers I am also having serious problems with ASYNC mode of those 2 commands (actually it seems I cannot get anything to be executed at all in ASYNC mode). I will study this better and if I find something out something maybe it is material for another bug report... ***** What IMHO is a more reasonable behaviour: py-execute-region and py-execute-buffer should behave in the same manner. The questions to answer are: 1) should the focus be returned to the calling source-code window when calling the functions above? 2a) If a *Python* interpreter window is present in the same frame ( (aa) or any frame, maybe? however this should at least be configurable since it is reasonable to have frames on remote machines) should no window be created? 2b) if there is No *Python* buffer visible in any window should a window be created and the contents displayed? 3) if there was no *Python* buffer opened AT ALL, (in most cases, the first time you call the execute functions), once created, should a visible window be created and the *Python* buffer displayed? The variable py-shell-switch-buffers-on-execute could control all, or a subset of these options. This is my proposal: Generally I suppose that it is reasonable that the answer to (3) should always be yes (always open the *python* buffer window on the inital startup of the buffer. (2b) Should absolutely be configurable! (2a) IMHO should not create any window if there are windows already visible. The check on (2aa) should not be implemented. That functionality can be obtained by configuring (2b) not to create windows and manually opening a window in an other frame. Finally, as for (1), I think focus should always be returned and the code to remember the exact original window should be fixed up, however this can also be made configurable. Anyway, sorry for so much talk! I have some experience in python and some other programming languages but lisp is rather new to me. I have recently got interested in hacking Emacs a bit so I will try to look into the code a bit myself. However I cannot promise anything. Bye!