started working on ruby 'script' execution

This commit is contained in:
Eric Schulte 2009-06-09 16:33:36 -07:00
parent f3da4d0321
commit 9c70974391
2 changed files with 13 additions and 14 deletions

View File

@ -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

View File

@ -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