Use tips to wrap a function on a call
save-window-excursionthat will restore the previous window after the command completes.
(defadvice py-execute-region
(around preserve-window-configuration activate)
"After execution, return cursor to script buffer"
(save-window-excursion ad-do-it))
Keep in mind that if the Python buffer has not yet been shown, it will still be hidden after the command completes. To fix this, you can add another tip to bring up the window for switching between buffers and other end windows:
(defadvice py-execute-region
(after show-pybuf-other-window activate)
"After execution, show the python buffer in another window."
(switch-to-buffer-other-window "[PYTHON BUFFER NAME]"))
Also, make sure that you are not using """triple quotes"""elisp. I do not think they work.
source
share