From a9069d8dfd779931880891a09838f2474f681313 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Wed, 11 Nov 2009 16:09:05 -0500 Subject: [PATCH] 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. --- contrib/babel/lisp/langs/org-babel-perl.el | 9 ++++----- contrib/babel/lisp/langs/org-babel-python.el | 11 ++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/contrib/babel/lisp/langs/org-babel-perl.el b/contrib/babel/lisp/langs/org-babel-perl.el index b6140666..1ecac538 100644 --- a/contrib/babel/lisp/langs/org-babel-perl.el +++ b/contrib/babel/lisp/langs/org-babel-perl.el @@ -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")) diff --git a/contrib/babel/lisp/langs/org-babel-python.el b/contrib/babel/lisp/langs/org-babel-python.el index 9234d89d..aceb41ae 100644 --- a/contrib/babel/lisp/langs/org-babel-python.el +++ b/contrib/babel/lisp/langs/org-babel-python.el @@ -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")) -- 2.11.4.GIT