Skip to content

Instantly share code, notes, and snippets.

@ydm
Created July 19, 2013 15:44
Show Gist options
  • Save ydm/6040155 to your computer and use it in GitHub Desktop.
Save ydm/6040155 to your computer and use it in GitHub Desktop.
Send current buffer to a freshly made python shell
(defun y:python-run ()
(interactive)
(let* ((dedicated-proc-name (python-shell-get-process-name t))
(dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name))
(dedicated-running (comint-check-proc dedicated-proc-buffer-name)))
;; If there's already a python shell running for this buffer, kill it
(when dedicated-running
(let* ((process (python-shell-get-or-create-process))
(buffer (process-buffer process)))
(set-process-query-on-exit-flag process nil)
(kill-buffer buffer)))
;; Start new python shell
(run-python python-shell-interpreter t)
(python-shell-send-buffer t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment