[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r115205: * python.el (python-shell-send-file): Add o
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] trunk r115205: * python.el (python-shell-send-file): Add option to delete file when done. |
Date: |
Sat, 23 Nov 2013 19:39:56 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 115205
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/15647
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Sat 2013-11-23 11:39:50 -0800
message:
* python.el (python-shell-send-file): Add option to delete file when done.
(python-shell-send-string, python-shell-send-region): Use it.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/python.el python.el-20091113204419-o5vbwnq5f7feedwu-3008
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-11-23 04:20:31 +0000
+++ b/lisp/ChangeLog 2013-11-23 19:39:50 +0000
@@ -1,3 +1,9 @@
+2013-11-23 Glenn Morris <address@hidden>
+
+ * progmodes/python.el (python-shell-send-file):
+ Add option to delete file when done. (Bug#15647)
+ (python-shell-send-string, python-shell-send-region): Use it.
+
2013-11-23 Ivan Shmakov <address@hidden> (tiny change)
* vc/diff-mode.el (diff-mode): Only allow diff-default-read-only
=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el 2013-11-23 04:20:31 +0000
+++ b/lisp/progmodes/python.el 2013-11-23 19:39:50 +0000
@@ -2056,7 +2056,7 @@
(let ((process (or process (python-shell-get-or-create-process))))
(if (string-match ".\n+." string) ;Multiline.
(let* ((temp-file-name (python-shell--save-temp-file string)))
- (python-shell-send-file temp-file-name process temp-file-name))
+ (python-shell-send-file temp-file-name process temp-file-name t))
(comint-send-string process string)
(when (or (not (string-match "\n\\'" string))
(string-match "\n[ \t].*\n?\\'" string))
@@ -2212,7 +2212,7 @@
(message "Sent: %s..." (match-string 1 string))
(let* ((temp-file-name (python-shell--save-temp-file string))
(file-name (or (buffer-file-name) temp-file-name)))
- (python-shell-send-file file-name process temp-file-name)
+ (python-shell-send-file file-name process temp-file-name t)
(unless python--use-fake-loc
(with-current-buffer (process-buffer process)
(compilation-fake-loc (copy-marker start) temp-file-name
@@ -2249,11 +2249,12 @@
(end-of-line 1))
(point-marker)))))
-(defun python-shell-send-file (file-name &optional process temp-file-name)
+(defun python-shell-send-file (file-name &optional process temp-file-name
+ delete)
"Send FILE-NAME to inferior Python PROCESS.
If TEMP-FILE-NAME is passed then that file is used for processing
instead, while internally the shell will continue to use
-FILE-NAME."
+FILE-NAME. If DELETE is non-nil, delete the file afterwards."
(interactive "fFile to send: ")
(let* ((process (or process (python-shell-get-or-create-process)))
(temp-file-name (when temp-file-name
@@ -2271,8 +2272,11 @@
(format
(concat "__pyfile = open('''%s''');"
"exec(compile(__pyfile.read(), '''%s''', 'exec'));"
- "__pyfile.close()")
- (or temp-file-name file-name) file-name)
+ "__pyfile.close()%s")
+ (or temp-file-name file-name) file-name
+ (if delete (format "; import os; os.remove('''%s''')"
+ (or temp-file-name file-name))
+ ""))
process)))
(defun python-shell-switch-to-shell ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r115205: * python.el (python-shell-send-file): Add option to delete file when done.,
Glenn Morris <=