org-babel: more robust version of :results value for python and perl.
In ':results value' ('functional') mode, a return statement is now required in python and perl code.
This commit is contained in:
parent
838363f047
commit
a9069d8dfd
|
@ -108,11 +108,10 @@ last statement in BODY, as elisp."
|
|||
(if (member "pp" result-params)
|
||||
(error "Pretty-printing not implemented for perl")
|
||||
org-babel-perl-wrapper-method)
|
||||
(let ((lines (split-string
|
||||
(org-remove-indentation (org-babel-trim body)) "[\r\n]")))
|
||||
(concat
|
||||
(mapconcat #'identity (butlast lines) "\n")
|
||||
(format "\nreturn %s" (car (last lines)))))
|
||||
(mapconcat
|
||||
(lambda (line) (format "\t%s" line))
|
||||
(split-string
|
||||
(org-remove-indentation (org-babel-trim body)) "[\r\n]") "\n")
|
||||
tmp-file))
|
||||
;; (message "buffer=%s" (buffer-string)) ;; debugging
|
||||
(shell-command-on-region (point-min) (point-max) "perl"))
|
||||
|
|
|
@ -160,13 +160,10 @@ last statement in BODY, as elisp."
|
|||
(if (member "pp" result-params)
|
||||
org-babel-python-pp-wrapper-method
|
||||
org-babel-python-wrapper-method)
|
||||
(let ((lines (split-string
|
||||
(org-remove-indentation (org-babel-trim body)) "[\r\n]")))
|
||||
(concat
|
||||
(mapconcat
|
||||
(lambda (line) (format "\t%s" line))
|
||||
(butlast lines) "\n")
|
||||
(format "\n\treturn %s" (car (last lines)))))
|
||||
(mapconcat
|
||||
(lambda (line) (format "\t%s" line))
|
||||
(split-string
|
||||
(org-remove-indentation (org-babel-trim body)) "[\r\n]") "\n")
|
||||
tmp-file))
|
||||
;; (message "buffer=%s" (buffer-string)) ;; debugging
|
||||
(shell-command-on-region (point-min) (point-max) "python"))
|
||||
|
|
Loading…
Reference in New Issue