C-c C-c
is bound to python-shell-send-buffer
by default. Normally, you'd run this command after creating a Python process via C-c C-p (run-python
), which will not prompt for anything by default.
If you always want to be able to hit C-c C-c, irrespective of whether there is a Python process or not, you can advise python-shell-send-buffer
as follows:
(defun python-shell-send-buffer-no-prompt (arg)
(python-shell-get-or-create-process "/usr/bin/python -i" nil t))
(advice-add 'python-shell-send-buffer :before #'python-shell-send-buffer-no-prompt)
In conjunction with the code you posted, this also takes care of popping to a new frame and displaying the *Python*
buffer there when it is first created: As the signature of python-shell-get-or-create-process
indicates, the last argument specifies whether the *Python*
buffer should be shown or not:
(python-shell-get-or-create-process &optional CMD DEDICATED SHOW)