diff options
| author | Stefan Monnier | 2013-11-12 14:11:22 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-11-12 14:11:22 -0500 |
| commit | 666ffc7e09d3f55e2ce370bc3cf0bda347ae2e21 (patch) | |
| tree | f9fd870f75195e853e0df4fd242055beacc360cc /lisp/org/ob-python.el | |
| parent | 32d15ad99ccc01985ac36db9f9fabdf721202b6d (diff) | |
| download | emacs-666ffc7e09d3f55e2ce370bc3cf0bda347ae2e21.tar.gz emacs-666ffc7e09d3f55e2ce370bc3cf0bda347ae2e21.zip | |
Address some byte-compiler warnings.
* lisp/org/ob-abc.el (org-babel-expand-body:abc): Use dolist.
(org-babel-execute:abc): Fix regexp quoting.
* lisp/org/ob-calc.el (org--var-syms): Rename from `var-syms'.
* lisp/org/ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
* lisp/org/ob-table.el (sbe): Move debug declaration.
* lisp/org/org-clock.el (org--msg-extra): Rename from `msg-extra'.
* lisp/org/org.el (org-version): Avoid var name starting with _.
(org-inhibit-startup, org-called-with-limited-levels)
(org-link-search-inhibit-query, org-time-was-given)
(org-end-time-was-given, org-def, org-defdecode, org-with-time):
* lisp/org/org-colview.el (org-agenda-overriding-columns-format):
* lisp/org/org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
(org-agenda-show-log-scoped):
* lisp/org/ob-python.el (py-which-bufname, python-shell-buffer-name):
* lisp/org/ob-haskell.el (org-export-copy-to-kill-ring):
* lisp/org/ob-exp.el (org-link-search-inhibit-query):
* lisp/org/ob-R.el (ess-eval-visibly-p):
* lisp/org/ob-core.el (org-src-window-setup): Declare before use.
(org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
* lisp/org/ox-odt.el (org-odt-hfy-face-to-css):
* lisp/org/org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
* lisp/org/org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
(org-bibtex-check):
* lisp/org/ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
(org-babel-tangle-single-block, org-babel-tangle-comment-links):
* ob-table.el (sbe):
* lisp/org/ob-sqlite.el (org-babel-sqlite-expand-vars):
* lisp/org/ob-sql.el (org-babel-sql-expand-vars):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
* lisp/org/ob-scala.el (org-babel-scala-evaluate):
* lisp/org/ob-ruby.el (org-babel-ruby-table-or-string)
(org-babel-ruby-evaluate):
* ob-python.el (org-babel-python-table-or-string)
(org-babel-python-evaluate-external-process)
(org-babel-python-evaluate-session):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-perl.el (org-babel-perl-evaluate):
* lisp/org/ob-maxima.el (org-babel-execute:maxima):
* lisp/org/ob-lisp.el (org-babel-execute:lisp):
* lisp/org/ob-java.el (org-babel-execute:java):
* lisp/org/ob-io.el (org-babel-io-evaluate):
* ob-haskell.el (org-babel-execute:haskell):
* lisp/org/ob-fortran.el (org-babel-execute:fortran):
* ob-exp.el (org-babel-exp-code):
* lisp/org/ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
* lisp/org/ob-ditaa.el (org-babel-execute:ditaa):
* ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
(org-babel-parse-header-arguments, org-babel-reassemble-table)
(org-babel-goto-src-block-head, org-babel-mark-block)
(org-babel-expand-noweb-references, org-babel-script-escape)
(org-babel-process-file-name):
* lisp/org/ob-clojure.el (org-babel-execute:clojure):
* ob-calc.el (org-babel-execute:calc):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* ob-abc.el (org-babel-execute:abc):
* ob-R.el (org-babel-expand-body:R):
* lisp/org/ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).
Diffstat (limited to 'lisp/org/ob-python.el')
| -rw-r--r-- | lisp/org/ob-python.el | 129 |
1 files changed, 66 insertions, 63 deletions
diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el index 17da109ca0b..b8f8a6daafa 100644 --- a/lisp/org/ob-python.el +++ b/lisp/org/ob-python.el | |||
| @@ -143,13 +143,12 @@ specifying a variable of the same value." | |||
| 143 | "Convert RESULTS into an appropriate elisp value. | 143 | "Convert RESULTS into an appropriate elisp value. |
| 144 | If the results look like a list or tuple, then convert them into an | 144 | If the results look like a list or tuple, then convert them into an |
| 145 | Emacs-lisp table, otherwise return the results as a string." | 145 | Emacs-lisp table, otherwise return the results as a string." |
| 146 | ((lambda (res) | 146 | (let ((res (org-babel-script-escape results))) |
| 147 | (if (listp res) | 147 | (if (listp res) |
| 148 | (mapcar (lambda (el) (if (equal el 'None) | 148 | (mapcar (lambda (el) (if (equal el 'None) |
| 149 | org-babel-python-None-to el)) | 149 | org-babel-python-None-to el)) |
| 150 | res) | 150 | res) |
| 151 | res)) | 151 | res))) |
| 152 | (org-babel-script-escape results))) | ||
| 153 | 152 | ||
| 154 | (defvar org-babel-python-buffers '((:default . "*Python*"))) | 153 | (defvar org-babel-python-buffers '((:default . "*Python*"))) |
| 155 | 154 | ||
| @@ -172,6 +171,8 @@ Emacs-lisp table, otherwise return the results as a string." | |||
| 172 | name))) | 171 | name))) |
| 173 | 172 | ||
| 174 | (defvar py-default-interpreter) | 173 | (defvar py-default-interpreter) |
| 174 | (defvar py-which-bufname) | ||
| 175 | (defvar python-shell-buffer-name) | ||
| 175 | (defun org-babel-python-initiate-session-by-key (&optional session) | 176 | (defun org-babel-python-initiate-session-by-key (&optional session) |
| 176 | "Initiate a python session. | 177 | "Initiate a python session. |
| 177 | If there is not a current inferior-process-buffer in SESSION | 178 | If there is not a current inferior-process-buffer in SESSION |
| @@ -252,34 +253,34 @@ open('%s', 'w').write( pprint.pformat(main()) )") | |||
| 252 | If RESULT-TYPE equals 'output then return standard output as a | 253 | If RESULT-TYPE equals 'output then return standard output as a |
| 253 | string. If RESULT-TYPE equals 'value then return the value of the | 254 | string. If RESULT-TYPE equals 'value then return the value of the |
| 254 | last statement in BODY, as elisp." | 255 | last statement in BODY, as elisp." |
| 255 | ((lambda (raw) | 256 | (let ((raw |
| 256 | (org-babel-result-cond result-params | 257 | (case result-type |
| 257 | raw | 258 | (output (org-babel-eval org-babel-python-command |
| 258 | (org-babel-python-table-or-string (org-babel-trim raw)))) | 259 | (concat (if preamble (concat preamble "\n")) |
| 259 | (case result-type | 260 | body))) |
| 260 | (output (org-babel-eval org-babel-python-command | 261 | (value (let ((tmp-file (org-babel-temp-file "python-"))) |
| 261 | (concat (if preamble (concat preamble "\n") "") | 262 | (org-babel-eval |
| 262 | body))) | 263 | org-babel-python-command |
| 263 | (value (let ((tmp-file (org-babel-temp-file "python-"))) | 264 | (concat |
| 264 | (org-babel-eval | 265 | (if preamble (concat preamble "\n") "") |
| 265 | org-babel-python-command | 266 | (format |
| 266 | (concat | 267 | (if (member "pp" result-params) |
| 267 | (if preamble (concat preamble "\n") "") | 268 | org-babel-python-pp-wrapper-method |
| 268 | (format | 269 | org-babel-python-wrapper-method) |
| 269 | (if (member "pp" result-params) | 270 | (mapconcat |
| 270 | org-babel-python-pp-wrapper-method | 271 | (lambda (line) (format "\t%s" line)) |
| 271 | org-babel-python-wrapper-method) | 272 | (split-string |
| 272 | (mapconcat | 273 | (org-remove-indentation |
| 273 | (lambda (line) (format "\t%s" line)) | 274 | (org-babel-trim body)) |
| 274 | (split-string | 275 | "[\r\n]") "\n") |
| 275 | (org-remove-indentation | 276 | (org-babel-process-file-name tmp-file 'noquote)))) |
| 276 | (org-babel-trim body)) | 277 | (org-babel-eval-read-file tmp-file)))))) |
| 277 | "[\r\n]") "\n") | 278 | (org-babel-result-cond result-params |
| 278 | (org-babel-process-file-name tmp-file 'noquote)))) | 279 | raw |
| 279 | (org-babel-eval-read-file tmp-file)))))) | 280 | (org-babel-python-table-or-string (org-babel-trim raw))))) |
| 280 | 281 | ||
| 281 | (defun org-babel-python-evaluate-session | 282 | (defun org-babel-python-evaluate-session |
| 282 | (session body &optional result-type result-params) | 283 | (session body &optional result-type result-params) |
| 283 | "Pass BODY to the Python process in SESSION. | 284 | "Pass BODY to the Python process in SESSION. |
| 284 | If RESULT-TYPE equals 'output then return standard output as a | 285 | If RESULT-TYPE equals 'output then return standard output as a |
| 285 | string. If RESULT-TYPE equals 'value then return the value of the | 286 | string. If RESULT-TYPE equals 'value then return the value of the |
| @@ -296,39 +297,41 @@ last statement in BODY, as elisp." | |||
| 296 | (format "open('%s', 'w').write(pprint.pformat(_))" | 297 | (format "open('%s', 'w').write(pprint.pformat(_))" |
| 297 | (org-babel-process-file-name tmp-file 'noquote))) | 298 | (org-babel-process-file-name tmp-file 'noquote))) |
| 298 | (list (format "open('%s', 'w').write(str(_))" | 299 | (list (format "open('%s', 'w').write(str(_))" |
| 299 | (org-babel-process-file-name tmp-file 'noquote))))))) | 300 | (org-babel-process-file-name tmp-file |
| 301 | 'noquote))))))) | ||
| 300 | (input-body (lambda (body) | 302 | (input-body (lambda (body) |
| 301 | (mapc (lambda (line) (insert line) (funcall send-wait)) | 303 | (mapc (lambda (line) (insert line) (funcall send-wait)) |
| 302 | (split-string body "[\r\n]")) | 304 | (split-string body "[\r\n]")) |
| 303 | (funcall send-wait)))) | 305 | (funcall send-wait))) |
| 304 | ((lambda (results) | 306 | (results |
| 305 | (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results) | 307 | (case result-type |
| 306 | (org-babel-result-cond result-params | 308 | (output |
| 307 | results | 309 | (mapconcat |
| 308 | (org-babel-python-table-or-string results)))) | 310 | #'org-babel-trim |
| 309 | (case result-type | 311 | (butlast |
| 310 | (output | 312 | (org-babel-comint-with-output |
| 311 | (mapconcat | 313 | (session org-babel-python-eoe-indicator t body) |
| 312 | #'org-babel-trim | 314 | (funcall input-body body) |
| 313 | (butlast | 315 | (funcall send-wait) (funcall send-wait) |
| 314 | (org-babel-comint-with-output | 316 | (insert org-babel-python-eoe-indicator) |
| 315 | (session org-babel-python-eoe-indicator t body) | 317 | (funcall send-wait)) |
| 316 | (funcall input-body body) | 318 | 2) "\n")) |
| 317 | (funcall send-wait) (funcall send-wait) | 319 | (value |
| 318 | (insert org-babel-python-eoe-indicator) | 320 | (let ((tmp-file (org-babel-temp-file "python-"))) |
| 319 | (funcall send-wait)) | 321 | (org-babel-comint-with-output |
| 320 | 2) "\n")) | 322 | (session org-babel-python-eoe-indicator nil body) |
| 321 | (value | 323 | (let ((comint-process-echoes nil)) |
| 322 | (let ((tmp-file (org-babel-temp-file "python-"))) | 324 | (funcall input-body body) |
| 323 | (org-babel-comint-with-output | 325 | (funcall dump-last-value tmp-file |
| 324 | (session org-babel-python-eoe-indicator nil body) | 326 | (member "pp" result-params)) |
| 325 | (let ((comint-process-echoes nil)) | 327 | (funcall send-wait) (funcall send-wait) |
| 326 | (funcall input-body body) | 328 | (insert org-babel-python-eoe-indicator) |
| 327 | (funcall dump-last-value tmp-file (member "pp" result-params)) | 329 | (funcall send-wait))) |
| 328 | (funcall send-wait) (funcall send-wait) | 330 | (org-babel-eval-read-file tmp-file)))))) |
| 329 | (insert org-babel-python-eoe-indicator) | 331 | (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results) |
| 330 | (funcall send-wait))) | 332 | (org-babel-result-cond result-params |
| 331 | (org-babel-eval-read-file tmp-file))))))) | 333 | results |
| 334 | (org-babel-python-table-or-string results))))) | ||
| 332 | 335 | ||
| 333 | (defun org-babel-python-read-string (string) | 336 | (defun org-babel-python-read-string (string) |
| 334 | "Strip 's from around Python string." | 337 | "Strip 's from around Python string." |