Skip to main content
replaced http://emacs.stackexchange.com/ with https://emacs.stackexchange.com/
Source Link

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))
Turn on syntax highlighting.
Source Link
itsjeyd
  • 14.9k
  • 3
  • 60
  • 87

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)
(defun python-shell-send-buffer-no-prompt (&optional 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)
(python-shell-get-or-create-process &optional CMD DEDICATED SHOW)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))
(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))
added 10 characters in body
Source Link
itsjeyd
  • 14.9k
  • 3
  • 60
  • 87

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))

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 follows1:

(defun python-shell-send-buffer-no-prompt (&optional 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)

1 This code was written to make use of the new advice system introduced in Emacs 24.4. If you are using an earlier version of Emacs, the following code will work:

(defadvice python-shell-send-buffer
    (before python-shell-send-buffer-no-prompt (&optional arg) activate compile)
  (python-shell-get-or-create-process "/usr/bin/python -i" nil t))
added 223 characters in body
Source Link
itsjeyd
  • 14.9k
  • 3
  • 60
  • 87
Loading
added 223 characters in body
Source Link
itsjeyd
  • 14.9k
  • 3
  • 60
  • 87
Loading
Source Link
itsjeyd
  • 14.9k
  • 3
  • 60
  • 87
Loading