emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 1ad16ffb95: ob-R.el: Restore the handling of org-li


From: ELPA Syncer
Subject: [elpa] externals/org 1ad16ffb95: ob-R.el: Restore the handling of org-list in as var
Date: Wed, 7 Dec 2022 16:57:51 -0500 (EST)

branch: externals/org
commit 1ad16ffb95ee1434ccc49ac553b895b37471f3cb
Author: Jeremie Juste <djj@debian-BULLSEYE-live-builder-AMD64>
Commit: Jeremie Juste <djj@debian-BULLSEYE-live-builder-AMD64>

    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.
---
 lisp/ob-R.el              |  4 ++--
 testing/lisp/test-ob-R.el | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index f68b5b44e4..b7f96a179a 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -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)
   "Construct R code assigning the elisp VALUE to a variable named NAME."
   (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))
             (min (if lengths (apply 'min lengths) 0)))
         ;; 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)))
              (header (if (or (eq (nth 1 value) 'hline) colnames-p)
                          "TRUE" "FALSE"))
diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el
index da142fb3cf..cbd5a36a2d 100644
--- a/testing/lisp/test-ob-R.el
+++ b/testing/lisp/test-ob-R.el
@@ -261,6 +261,41 @@ log10(10)
                     (string= (concat src-block result)
                              (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)
 
 ;;; test-ob-R.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]