From 39d1674f30bac72200e9c995108aeac0dec2458e Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 9 Jun 2009 15:28:59 -0700 Subject: [PATCH] org-babel-R is now able to assign variables --- lisp/org-babel-R.el | 3 ++- lisp/org-babel-ref.el | 3 ++- lisp/org-babel.el | 2 +- org-babel.org | 31 +++++++++++++++++++++++++------ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lisp/org-babel-R.el b/lisp/org-babel-R.el index c9949790e..713de0df7 100644 --- a/lisp/org-babel-R.el +++ b/lisp/org-babel-R.el @@ -47,8 +47,9 @@ called by `org-babel-execute-src-block'." (message "executing R source code block...") (save-window-excursion (let ((vars (org-babel-ref-variables params)) - (results-params (split-string (cdr (assoc :results params)))) + (results-params (split-string (or (cdr (assoc :results params)) ""))) results) + ;; (message (format "%S" results-params)) (org-babel-R-initiate-R-buffer) (mapc (lambda (pair) (org-babel-R-assign-elisp (car pair) (cdr pair))) vars) (cond diff --git a/lisp/org-babel-ref.el b/lisp/org-babel-ref.el index b41dea656..4af169f78 100644 --- a/lisp/org-babel-ref.el +++ b/lisp/org-babel-ref.el @@ -132,7 +132,8 @@ return nil." (mapcar #'org-babel-read row))) (org-table-to-lisp))) ('source-block - (setq result (org-babel-execute-src-block t nil args)) + (setq result (org-babel-execute-src-block + t nil (org-combine-plists args '((:results . "last"))))) (if (symbolp result) (format "%S" result) result)))))) (defun org-babel-ref-at-ref-p () diff --git a/lisp/org-babel.el b/lisp/org-babel.el index 7d1327ba9..9a7570257 100644 --- a/lisp/org-babel.el +++ b/lisp/org-babel.el @@ -119,7 +119,7 @@ the header arguments specified at the source code block." (let* ((info (or info (org-babel-get-src-block-info))) (lang (first info)) (body (second info)) - (params (org-combine-plists (third info) params)) + (params (org-combine-plists params (third info))) (cmd (intern (concat "org-babel-execute:" lang))) result) ;; (message (format "params=%S" params)) ;; debugging statement diff --git a/org-babel.org b/org-babel.org index 57c4f9e94..3d5a828cd 100644 --- a/org-babel.org +++ b/org-babel.org @@ -465,7 +465,7 @@ for the execution of source-code blocks. with the results (this implies the *script* =:results= argument as well) -*** TODO rework evaluation lang-by-lang [0/4] +*** TODO rework evaluation lang-by-lang [1/4] This should include... - functional results working with the comint buffer @@ -478,16 +478,16 @@ This should include... - sessions in comint buffers -**** TODO R +**** DONE R [3/3] - [X] functional results working with comint - [X] script results -- [ ] implement echo +- [X] ensure callable by other source block To redirect output to a file, you can use the =sink()= command. -#+srcname: task-R-with-inf-process-buffer -#+begin_src R :results replace script scalar +#+srcname: task_R_B +#+begin_src R :results replace script a <- 8 b <- 9 c <- 10 @@ -501,7 +501,26 @@ a + b + c : [1] 21 : [1] 27 -**** TODO Ruby +#+srcname: task-R-use-other-output +#+begin_src R :var twoentyseven=task_R_B() :results replace script +83 +twoentyseven +#+end_src + +#+resname: task-R-use-other-output +: [1] 83 +: [1] 27 + +#+srcname: name +#+begin_src emacs-lisp +(setq debug-on-error t) +#+end_src + +**** TODO Ruby [0/3] + +- [ ] functional results working with comint +- [ ] script results +- [ ] ensure callable by other source block #+srcname: ruby-use-last-output #+begin_src ruby