diff options
| author | Rasmus | 2018-01-22 15:57:42 +0100 |
|---|---|---|
| committer | Rasmus | 2018-01-22 16:02:55 +0100 |
| commit | bb396a369c93e57b033844003c7ceab61d61aa08 (patch) | |
| tree | 31a9ef7d5792d64bf181b17cb8255386efd5d96d /lisp/org/ob-python.el | |
| parent | fa582153f7a75e1eaaef4bfd2b381916233dc0a7 (diff) | |
| download | emacs-bb396a369c93e57b033844003c7ceab61d61aa08.tar.gz emacs-bb396a369c93e57b033844003c7ceab61d61aa08.zip | |
Update Org to v9.1.6
Please note this is a bugfix release. See etc/ORG-NEWS for details.
Diffstat (limited to 'lisp/org/ob-python.el')
| -rw-r--r-- | lisp/org/ob-python.el | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el index 3ea050fffea..951e4d2a4b4 100644 --- a/lisp/org/ob-python.el +++ b/lisp/org/ob-python.el | |||
| @@ -239,6 +239,15 @@ def main(): | |||
| 239 | 239 | ||
| 240 | open('%s', 'w').write( pprint.pformat(main()) )") | 240 | open('%s', 'w').write( pprint.pformat(main()) )") |
| 241 | 241 | ||
| 242 | (defconst org-babel-python--exec-tmpfile | ||
| 243 | (concat | ||
| 244 | "__org_babel_python_fname = '%s'; " | ||
| 245 | "__org_babel_python_fh = open(__org_babel_python_fname); " | ||
| 246 | "exec(compile(" | ||
| 247 | "__org_babel_python_fh.read(), __org_babel_python_fname, 'exec'" | ||
| 248 | ")); " | ||
| 249 | "__org_babel_python_fh.close()")) | ||
| 250 | |||
| 242 | (defun org-babel-python-evaluate | 251 | (defun org-babel-python-evaluate |
| 243 | (session body &optional result-type result-params preamble) | 252 | (session body &optional result-type result-params preamble) |
| 244 | "Evaluate BODY as Python code." | 253 | "Evaluate BODY as Python code." |
| @@ -306,16 +315,23 @@ last statement in BODY, as elisp." | |||
| 306 | (results | 315 | (results |
| 307 | (pcase result-type | 316 | (pcase result-type |
| 308 | (`output | 317 | (`output |
| 309 | (mapconcat | 318 | (let ((body (if (string-match-p ".\n+." body) ; Multiline |
| 310 | #'org-trim | 319 | (let ((tmp-src-file (org-babel-temp-file |
| 311 | (butlast | 320 | "python-"))) |
| 312 | (org-babel-comint-with-output | 321 | (with-temp-file tmp-src-file (insert body)) |
| 313 | (session org-babel-python-eoe-indicator t body) | 322 | (format org-babel-python--exec-tmpfile |
| 314 | (funcall input-body body) | 323 | tmp-src-file)) |
| 315 | (funcall send-wait) (funcall send-wait) | 324 | body))) |
| 316 | (insert org-babel-python-eoe-indicator) | 325 | (mapconcat |
| 317 | (funcall send-wait)) | 326 | #'org-trim |
| 318 | 2) "\n")) | 327 | (butlast |
| 328 | (org-babel-comint-with-output | ||
| 329 | (session org-babel-python-eoe-indicator t body) | ||
| 330 | (funcall input-body body) | ||
| 331 | (funcall send-wait) (funcall send-wait) | ||
| 332 | (insert org-babel-python-eoe-indicator) | ||
| 333 | (funcall send-wait)) | ||
| 334 | 2) "\n"))) | ||
| 319 | (`value | 335 | (`value |
| 320 | (let ((tmp-file (org-babel-temp-file "python-"))) | 336 | (let ((tmp-file (org-babel-temp-file "python-"))) |
| 321 | (org-babel-comint-with-output | 337 | (org-babel-comint-with-output |