diff options
| author | Bastien | 2019-12-03 23:27:04 +0100 |
|---|---|---|
| committer | Bastien | 2019-12-03 23:27:04 +0100 |
| commit | 165f7383822086d465519ebe6e4283723923f097 (patch) | |
| tree | 820be9480e3d571d766483f564c963037192f6ec /lisp/org/ob-python.el | |
| parent | 821de968434d2096bdea67dd24301bf6b517aef1 (diff) | |
| download | emacs-165f7383822086d465519ebe6e4283723923f097.tar.gz emacs-165f7383822086d465519ebe6e4283723923f097.zip | |
Update Org to 9.3
Diffstat (limited to 'lisp/org/ob-python.el')
| -rw-r--r-- | lisp/org/ob-python.el | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el index b10320ee532..c36bf2dcd0f 100644 --- a/lisp/org/ob-python.el +++ b/lisp/org/ob-python.el | |||
| @@ -28,9 +28,8 @@ | |||
| 28 | 28 | ||
| 29 | ;;; Code: | 29 | ;;; Code: |
| 30 | (require 'ob) | 30 | (require 'ob) |
| 31 | (require 'org-macs) | ||
| 31 | 32 | ||
| 32 | (declare-function org-remove-indentation "org" ) | ||
| 33 | (declare-function org-trim "org" (s &optional keep-lead)) | ||
| 34 | (declare-function py-shell "ext:python-mode" (&optional argprompt)) | 33 | (declare-function py-shell "ext:python-mode" (&optional argprompt)) |
| 35 | (declare-function py-toggle-shells "ext:python-mode" (arg)) | 34 | (declare-function py-toggle-shells "ext:python-mode" (arg)) |
| 36 | (declare-function run-python "ext:python" (&optional cmd dedicated show)) | 35 | (declare-function run-python "ext:python" (&optional cmd dedicated show)) |
| @@ -266,13 +265,13 @@ last statement in BODY, as elisp." | |||
| 266 | (let ((raw | 265 | (let ((raw |
| 267 | (pcase result-type | 266 | (pcase result-type |
| 268 | (`output (org-babel-eval org-babel-python-command | 267 | (`output (org-babel-eval org-babel-python-command |
| 269 | (concat (if preamble (concat preamble "\n")) | 268 | (concat preamble (and preamble "\n") |
| 270 | body))) | 269 | body))) |
| 271 | (`value (let ((tmp-file (org-babel-temp-file "python-"))) | 270 | (`value (let ((tmp-file (org-babel-temp-file "python-"))) |
| 272 | (org-babel-eval | 271 | (org-babel-eval |
| 273 | org-babel-python-command | 272 | org-babel-python-command |
| 274 | (concat | 273 | (concat |
| 275 | (if preamble (concat preamble "\n") "") | 274 | preamble (and preamble "\n") |
| 276 | (format | 275 | (format |
| 277 | (if (member "pp" result-params) | 276 | (if (member "pp" result-params) |
| 278 | org-babel-python-pp-wrapper-method | 277 | org-babel-python-pp-wrapper-method |
| @@ -308,9 +307,21 @@ last statement in BODY, as elisp." | |||
| 308 | (list (format "open('%s', 'w').write(str(_))" | 307 | (list (format "open('%s', 'w').write(str(_))" |
| 309 | (org-babel-process-file-name tmp-file | 308 | (org-babel-process-file-name tmp-file |
| 310 | 'noquote))))))) | 309 | 'noquote))))))) |
| 310 | (last-indent 0) | ||
| 311 | (input-body (lambda (body) | 311 | (input-body (lambda (body) |
| 312 | (mapc (lambda (line) (insert line) (funcall send-wait)) | 312 | (dolist (line (split-string body "[\r\n]")) |
| 313 | (split-string body "[\r\n]")) | 313 | ;; Insert a blank line to end an indent |
| 314 | ;; block. | ||
| 315 | (let ((curr-indent (string-match "\\S-" line))) | ||
| 316 | (if curr-indent | ||
| 317 | (progn | ||
| 318 | (when (< curr-indent last-indent) | ||
| 319 | (insert "") | ||
| 320 | (funcall send-wait)) | ||
| 321 | (setq last-indent curr-indent)) | ||
| 322 | (setq last-indent 0))) | ||
| 323 | (insert line) | ||
| 324 | (funcall send-wait)) | ||
| 314 | (funcall send-wait))) | 325 | (funcall send-wait))) |
| 315 | (results | 326 | (results |
| 316 | (pcase result-type | 327 | (pcase result-type |