aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/org/ob-python.el
diff options
context:
space:
mode:
authorPaul Eggert2018-01-22 08:43:54 -0800
committerPaul Eggert2018-01-22 08:43:54 -0800
commit35675bb93f4620c43ca766e8a2d8708fd323c684 (patch)
treed52b1a6b58c517f53689a4f2fe513d7c78b02b1d /lisp/org/ob-python.el
parentc42959cc206bcb52baffd45f892da1b767f0f8c1 (diff)
parent1fc98ed073a2d26ad941748ecb13aa6f47dd7b01 (diff)
downloademacs-35675bb93f4620c43ca766e8a2d8708fd323c684.tar.gz
emacs-35675bb93f4620c43ca766e8a2d8708fd323c684.zip
Merge from origin/emacs-26
1fc98ed073 ; Spelling fix bb396a369c Update Org to v9.1.6 fa582153f7 Use text-pixels values only when saving framesets (Bug#30141) 6b01b9475d Minor improvement in section "Pages" of the usere manual e8c8bd3de2 Minor improvements in user manual 26b8b92e63 Improve the "Mark" chapter of the user manual 759569fe40 Improve the "Buffers" chapter of the user manual c2e6d121ff * lisp/term.el (term-send-input): Fix text duplication in ... 854a1c0a61 Improve "Buffers" in the user manual # Conflicts: # etc/NEWS
Diffstat (limited to 'lisp/org/ob-python.el')
-rw-r--r--lisp/org/ob-python.el36
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
240open('%s', 'w').write( pprint.pformat(main()) )") 240open('%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