浏览代码

org-babel-R is now able to assign variables

Eric Schulte 16 年之前
父节点
当前提交
39d1674f30
共有 4 个文件被更改,包括 30 次插入9 次删除
  1. 2 1
      lisp/org-babel-R.el
  2. 2 1
      lisp/org-babel-ref.el
  3. 1 1
      lisp/org-babel.el
  4. 25 6
      org-babel.org

+ 2 - 1
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

+ 2 - 1
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 ()

+ 1 - 1
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

+ 25 - 6
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