ob-R.el: Restore the handling of org-list in as var
* ob-R.el (org-babel-R-assign-elisp): Use the patch from
ccberry@health.ucsd.edu, to print org-list as a one column table as it
was the case in release_9.5. The break in R is due commit b4e437f96
*
ob-core: Resolve named list references to simple lists.
* test-ob-R.el (ob-R-nested-list): New function to test that org list
with multiple level are handled as expected in R.
see https://list.orgmode.org/87bkofh0ir.fsf@localhost/ for context.
This commit is contained in:
parent
08433d9b0c
commit
1ad16ffb95
|
@ -241,11 +241,11 @@ This function is called by `org-babel-execute-src-block'."
|
||||||
(defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
|
(defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
|
||||||
"Construct R code assigning the elisp VALUE to a variable named NAME."
|
"Construct R code assigning the elisp VALUE to a variable named NAME."
|
||||||
(if (listp value)
|
(if (listp value)
|
||||||
(let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
|
(let* ((lengths (mapcar 'length (cl-remove-if-not 'listp value)))
|
||||||
(max (if lengths (apply 'max lengths) 0))
|
(max (if lengths (apply 'max lengths) 0))
|
||||||
(min (if lengths (apply 'min lengths) 0)))
|
(min (if lengths (apply 'min lengths) 0)))
|
||||||
;; Ensure VALUE has an orgtbl structure (depth of at least 2).
|
;; Ensure VALUE has an orgtbl structure (depth of at least 2).
|
||||||
(unless (listp (car value)) (setq value (list value)))
|
(unless (listp (car value)) (setq value (mapcar 'list value)))
|
||||||
(let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
|
(let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field)))
|
||||||
(header (if (or (eq (nth 1 value) 'hline) colnames-p)
|
(header (if (or (eq (nth 1 value) 'hline) colnames-p)
|
||||||
"TRUE" "FALSE"))
|
"TRUE" "FALSE"))
|
||||||
|
|
|
@ -261,6 +261,41 @@ log10(10)
|
||||||
(string= (concat src-block result)
|
(string= (concat src-block result)
|
||||||
(buffer-string)))))))
|
(buffer-string)))))))
|
||||||
|
|
||||||
|
|
||||||
|
;; test for printing of (nested) list
|
||||||
|
(ert-deftest ob-R-nested-list ()
|
||||||
|
"List are printed as the first column of a table and nested lists are ignored"
|
||||||
|
(let (ess-ask-for-ess-directory
|
||||||
|
ess-history-file
|
||||||
|
org-confirm-babel-evaluate
|
||||||
|
(org-babel-temporary-directory "/tmp")
|
||||||
|
(text "
|
||||||
|
#+NAME: example-list
|
||||||
|
- simple
|
||||||
|
- not
|
||||||
|
- nested
|
||||||
|
- list
|
||||||
|
|
||||||
|
#+BEGIN_SRC R :var x=example-list
|
||||||
|
x
|
||||||
|
#+END_SRC
|
||||||
|
")
|
||||||
|
(result "
|
||||||
|
#+RESULTS:
|
||||||
|
| simple |
|
||||||
|
| list |
|
||||||
|
"))
|
||||||
|
(org-test-with-temp-text-in-file
|
||||||
|
text
|
||||||
|
(goto-char (point-min))
|
||||||
|
(org-babel-next-src-block)
|
||||||
|
(should (progn
|
||||||
|
(org-babel-execute-src-block)
|
||||||
|
(sleep-for 0 200)
|
||||||
|
(string= (concat text result)
|
||||||
|
(buffer-string)))))))
|
||||||
|
|
||||||
|
|
||||||
(provide 'test-ob-R)
|
(provide 'test-ob-R)
|
||||||
|
|
||||||
;;; test-ob-R.el ends here
|
;;; test-ob-R.el ends here
|
||||||
|
|
Loading…
Reference in New Issue