From 9c7097439114bc132484bf71e0125bd26c94dace Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 9 Jun 2009 16:33:36 -0700 Subject: [PATCH] started working on ruby 'script' execution --- lisp/org-babel-script.el | 21 ++++++++++++--------- org-babel.org | 6 +----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lisp/org-babel-script.el b/lisp/org-babel-script.el index 0d301e1d1..d3eed2fbe 100644 --- a/lisp/org-babel-script.el +++ b/lisp/org-babel-script.el @@ -71,9 +71,14 @@ executed through org-babel." (cond ((member "script" results-params) ;; collect all output (let ((tmp-file (make-temp-file "org-babel-R-script-output"))) - (org-babel-comint-input-command org-babel-R-buffer (format "sink(%S)" tmp-file)) - (org-babel-comint-input-command org-babel-R-buffer body) - (org-babel-comint-input-command org-babel-R-buffer "sink()") + ;; this is totally not working well + (org-babel-script-input-command interpreter (concat + "org_babel_io_holder = $stdout;" + (format "org_babel_tmp_file_holder = File.open('%s', 'w'); " tmp-file) + "$stdout = org_babel_tmp_file_holder; " + body + "org_babel_tmp_file_holder.flush; " + "$stdout = org_babel_io_holder;")) (with-temp-buffer (insert-file-contents tmp-file) (buffer-string)))) ((member "last" results-params) ;; the value of the last statement (org-babel-script-input-command interpreter full-body) @@ -126,14 +131,12 @@ then create. Return the initialized session." (current-buffer)))))) (defun org-babel-script-input-command (interpreter cmd) - (setq cmd (org-babel-chomp cmd)) - (message (format "input = %S" cmd)) - (org-babel-comint-input-command (eval (org-babel-script-session interpreter)) cmd)) + (org-babel-comint-input-command + (eval (org-babel-script-session interpreter)) (org-babel-chomp cmd))) (defun org-babel-script-command-to-string (interpreter cmd) - (setq cmd (org-babel-chomp cmd)) - (message (format "string = %S" cmd)) - (org-babel-comint-command-to-string (eval (org-babel-script-session interpreter)) cmd)) + (org-babel-comint-command-to-string + (eval (org-babel-script-session interpreter)) (org-babel-chomp cmd))) (provide 'org-babel-script) ;;; org-babel-script.el ends here diff --git a/org-babel.org b/org-babel.org index 75e160eb2..725aa6ba4 100644 --- a/org-babel.org +++ b/org-babel.org @@ -525,17 +525,13 @@ twoentyseven - [ ] rename buffer after session #+srcname: ruby-use-last-output -#+begin_src ruby :results replace last +#+begin_src ruby :results replace script a = 2 b = 4 c = a + b c * (a + b) #+end_src -#+resname: ruby-use-last-output -: 36 - - **** TODO Python **** TODO Shells