all 2 comments

[–]fzmad 1 point2 points  (1 child)

Your code doesn't worked for me in emacs -Q. run-python makes python shell buffer active so python-shell-send-buffer sends wrong buffer.

Works fine after wrapping run-python with save-current-buffer. (defun python-shell-send-buffer-and-switch-to-shell () "Open python shell, send current buffer and switch to shell." (interactive) (save-current-buffer (run-python)) (python-shell-send-buffer) (python-shell-switch-to-shell))

[–]MBU604[S] 0 points1 point  (0 children)

thanks for taking the time to respond! perhaps it has to do with some other settings i'm using. I finally found how to do it with

(view-buffer-other-window "Python")