Created
February 2, 2013 06:12
-
-
Save v2e4lisp/4696291 to your computer and use it in GitHub Desktop.
python-eval eval python code in the current buffer [Emacs]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun python-eval () | |
" Eval python code in current buffer. | |
It seems that the default python-mode doesn't have this function" | |
(interactive) | |
(let ((script-py (buffer-file-name)) | |
(tmp-script-py "/Users/wenjunyan/.test-code.py") | |
(output-buffer "*python-eval-output*")) | |
(if script-py | |
(progn | |
(when (buffer-modified-p) | |
(when (y-or-n-p "This buffer is modified. Save it to file ?") | |
(save-buffer))) | |
(shell-command (concat "python " script-py) output-buffer)) | |
(write-file tmp-script-py) | |
(kill-buffer) | |
(shell-command (concat "python " tmp-script-py) output-buffer) | |
(delete-file tmp-script-py)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment