diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:02:52 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:02:52 -0300 |
| commit | 66b0b492bcb40a7d0675ed3471da92aae4bde0ba (patch) | |
| tree | af9ec7aeef3463019402a42152df7e3d3b16b0aa /lisp/progmodes/python.el | |
| parent | 6ac2041b868fb13d2838a83a1e7bd565f9dcd81c (diff) | |
| download | emacs-66b0b492bcb40a7d0675ed3471da92aae4bde0ba.tar.gz emacs-66b0b492bcb40a7d0675ed3471da92aae4bde0ba.zip | |
Generalized use of python-shell-send-file with cleanup of prompts.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 122b44a9dde..6458c359355 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1002,8 +1002,7 @@ commands.)" | |||
| 1002 | (let* ((contents (buffer-substring start end)) | 1002 | (let* ((contents (buffer-substring start end)) |
| 1003 | (current-file (buffer-file-name)) | 1003 | (current-file (buffer-file-name)) |
| 1004 | (process (python-shell-get-or-create-process)) | 1004 | (process (python-shell-get-or-create-process)) |
| 1005 | (temp-file (make-temp-file "py")) | 1005 | (temp-file (make-temp-file "py"))) |
| 1006 | (process-buffer (process-buffer process))) | ||
| 1007 | (with-temp-file temp-file | 1006 | (with-temp-file temp-file |
| 1008 | (insert contents) | 1007 | (insert contents) |
| 1009 | (delete-trailing-whitespace) | 1008 | (delete-trailing-whitespace) |
| @@ -1013,12 +1012,8 @@ commands.)" | |||
| 1013 | (line-end-position))))) | 1012 | (line-end-position))))) |
| 1014 | (with-current-buffer (process-buffer process) | 1013 | (with-current-buffer (process-buffer process) |
| 1015 | (setq inferior-python-mode-current-file current-file) | 1014 | (setq inferior-python-mode-current-file current-file) |
| 1016 | (setq inferior-python-mode-current-temp-file temp-file) | 1015 | (setq inferior-python-mode-current-temp-file temp-file)) |
| 1017 | (delete-region (save-excursion | 1016 | (python-shell-send-file temp-file process))) |
| 1018 | (move-to-column 0) | ||
| 1019 | (point-marker)) | ||
| 1020 | (line-end-position))) | ||
| 1021 | (comint-send-string process (format "execfile(r'%s')\n" temp-file)))) | ||
| 1022 | 1017 | ||
| 1023 | (defun python-shell-send-buffer () | 1018 | (defun python-shell-send-buffer () |
| 1024 | "Send the entire buffer to inferior Python process." | 1019 | "Send the entire buffer to inferior Python process." |
| @@ -1041,12 +1036,19 @@ When argument ARG is non-nil sends the innermost defun." | |||
| 1041 | (or (python-end-of-defun-function) | 1036 | (or (python-end-of-defun-function) |
| 1042 | (progn (end-of-line) (point-marker))))))) | 1037 | (progn (end-of-line) (point-marker))))))) |
| 1043 | 1038 | ||
| 1044 | (defun python-shell-send-file (file-name) | 1039 | (defun python-shell-send-file (file-name &optional process) |
| 1045 | "Send FILE-NAME to inferior Python process." | 1040 | "Send FILE-NAME to inferior Python process." |
| 1046 | (interactive "fFile to send: ") | 1041 | (interactive "fFile to send: ") |
| 1047 | (comint-send-string | 1042 | (let ((process (or process (python-shell-get-or-create-process)))) |
| 1048 | (python-shell-get-or-create-process) | 1043 | (accept-process-output process) |
| 1049 | (format "execfile('%s')\n" (expand-file-name file-name)))) | 1044 | (with-current-buffer (process-buffer process) |
| 1045 | (delete-region (save-excursion | ||
| 1046 | (move-to-column 0) | ||
| 1047 | (point-marker)) | ||
| 1048 | (line-end-position))) | ||
| 1049 | (comint-send-string | ||
| 1050 | process | ||
| 1051 | (format "execfile('%s')\n" (expand-file-name file-name))))) | ||
| 1050 | 1052 | ||
| 1051 | (defun python-shell-switch-to-shell () | 1053 | (defun python-shell-switch-to-shell () |
| 1052 | "Switch to inferior Python process buffer." | 1054 | "Switch to inferior Python process buffer." |
| @@ -1098,8 +1100,7 @@ It is specially designed to be added to the | |||
| 1098 | (insert python-shell-completion-setup-code) | 1100 | (insert python-shell-completion-setup-code) |
| 1099 | (delete-trailing-whitespace) | 1101 | (delete-trailing-whitespace) |
| 1100 | (goto-char (point-min))) | 1102 | (goto-char (point-min))) |
| 1101 | (comint-send-string process | 1103 | (python-shell-send-file temp-file process) |
| 1102 | (format "execfile(r'%s')\n" temp-file)) | ||
| 1103 | (message (format "Completion setup code sent."))) | 1104 | (message (format "Completion setup code sent."))) |
| 1104 | (add-to-list (make-local-variable | 1105 | (add-to-list (make-local-variable |
| 1105 | 'comint-dynamic-complete-functions) | 1106 | 'comint-dynamic-complete-functions) |
| @@ -1423,8 +1424,7 @@ It is specially designed to be added to the | |||
| 1423 | (insert python-eldoc-setup-code) | 1424 | (insert python-eldoc-setup-code) |
| 1424 | (delete-trailing-whitespace) | 1425 | (delete-trailing-whitespace) |
| 1425 | (goto-char (point-min))) | 1426 | (goto-char (point-min))) |
| 1426 | (comint-send-string (get-buffer-process (current-buffer)) | 1427 | (python-shell-send-file temp-file (get-buffer-process (current-buffer))) |
| 1427 | (format "execfile(r'%s')\n" temp-file)) | ||
| 1428 | (message (format "Completion setup code sent."))))) | 1428 | (message (format "Completion setup code sent."))))) |
| 1429 | 1429 | ||
| 1430 | (defun python-eldoc-function () | 1430 | (defun python-eldoc-function () |