aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/python.el21
1 files changed, 8 insertions, 13 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ad2d47b2b24..737730d7823 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1018,11 +1018,12 @@ commands.)"
1018 dedicated-proc-buffer-name 1018 dedicated-proc-buffer-name
1019 global-proc-buffer-name)))) 1019 global-proc-buffer-name))))
1020 1020
1021(defun python-shell-send-string (string) 1021(defun python-shell-send-string (string &optional process)
1022 "Send STRING to inferior Python process." 1022 "Send STRING to inferior Python process."
1023 (interactive "sPython command: ") 1023 (interactive "sPython command: ")
1024 (let ((process (python-shell-get-or-create-process))) 1024 (let ((process (or process (python-shell-get-or-create-process))))
1025 (message (format "Sent: %s..." string)) 1025 (when (called-interactively-p)
1026 (message (format "Sent: %s..." string)))
1026 (comint-send-string process string) 1027 (comint-send-string process string)
1027 (when (or (not (string-match "\n$" string)) 1028 (when (or (not (string-match "\n$" string))
1028 (string-match "\n[ \t].*\n?$" string)) 1029 (string-match "\n[ \t].*\n?$" string))
@@ -1073,17 +1074,11 @@ When argument ARG is non-nil sends the innermost defun."
1073 (interactive "fFile to send: ") 1074 (interactive "fFile to send: ")
1074 (let ((process (or process (python-shell-get-or-create-process))) 1075 (let ((process (or process (python-shell-get-or-create-process)))
1075 (full-file-name (expand-file-name file-name))) 1076 (full-file-name (expand-file-name file-name)))
1076 (accept-process-output process) 1077 (python-shell-send-string
1077 (with-current-buffer (process-buffer process)
1078 (delete-region (save-excursion
1079 (move-to-column 0)
1080 (point-marker))
1081 (line-end-position)))
1082 (comint-send-string
1083 process
1084 (format 1078 (format
1085 "with open('%s') as __pyfile: exec(compile(__pyfile.read(), '%s', 'exec'))\n\n" 1079 "__pyfile = open('%s'); exec(compile(__pyfile.read(), '%s', 'exec')); __pyfile.close()"
1086 full-file-name full-file-name)))) 1080 full-file-name full-file-name)
1081 process)))
1087 1082
1088(defun python-shell-switch-to-shell () 1083(defun python-shell-switch-to-shell ()
1089 "Switch to inferior Python process buffer." 1084 "Switch to inferior Python process buffer."