branch: externals/org
commit c375381a0d5f00a66cb1905a550a47074a3f5d45
Author: Rudolf Adamkovič <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    ob-scheme: Fix errors when the result is a cons cell
    
    * lisp/ob-scheme.el (org-babel-scheme-null-to): Improve docstring.
    (org-babel-scheme--table-or-string): Fix Org Babel crashing with
    'Wrong type argument: listp, 2' when the result is a cons cell.  Also
    improve the docstring.
    * testing/lisp/test-ob-scheme.el (test-ob-scheme/list): Rename the
    test to `test-ob-scheme/proper-list' in order to differentiate proper
    lists from cons cells.  Also re-indent.
    (test-ob-scheme/cons-cell): Add a test to avoid future regressions.
    (test-ob-scheme/proper-list): The renamed test.
    
    Reported-by: "tusharhero" <[email protected]>
    Link: 
https://list.orgmode.org/[email protected]
---
 lisp/ob-scheme.el              |  8 ++++----
 testing/lisp/test-ob-scheme.el | 26 +++++++++++++++++++-------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index 4e476d40ed..4627123267 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -69,7 +69,7 @@
 (declare-function geiser-eval--error-msg "ext:geiser-eval" (err))
 
 (defcustom org-babel-scheme-null-to 'hline
-  "Replace `null' and empty lists in scheme tables with this before returning."
+  "Replacement for `()' and `null' in tabulated Scheme results."
   :group 'org-babel
   :version "26.1"
   :package-version '(Org . "9.1")
@@ -232,9 +232,9 @@ is true; otherwise returns the last value."
     result))
 
 (defun org-babel-scheme--table-or-string (results)
-  "Convert RESULTS into an appropriate elisp value.
-If the results look like a list or tuple, then convert them into an
-Emacs-lisp table, otherwise return the results as a string."
+  "Convert RESULTS into an appropriate Elisp value.
+If the results are in the form of a proper list, then convert them into
+an Emacs Lisp table, otherwise return the results as a string."
   (let ((res (and results (org-babel-script-escape results))))
     (cond ((proper-list-p res)
            (mapcar (lambda (el)
diff --git a/testing/lisp/test-ob-scheme.el b/testing/lisp/test-ob-scheme.el
index 81f3e25266..9fd2e9afdc 100644
--- a/testing/lisp/test-ob-scheme.el
+++ b/testing/lisp/test-ob-scheme.el
@@ -54,15 +54,27 @@
            (buffer-substring-no-properties (line-beginning-position 2)
                                            (point-max))))))
 
-(ert-deftest test-ob-scheme/list ()
-  "Test list output."
+(ert-deftest test-ob-scheme/cons-cell ()
+  "Test cons cell output."
+  (should
+   (equal ": (1 . 2)\n"
+         (org-test-with-temp-text
+           "#+begin_src scheme\n(cons 1 2)\n#+end_src"
+          (org-babel-execute-maybe)
+          (let ((case-fold-search t)) (search-forward "#+results"))
+          (buffer-substring-no-properties (line-beginning-position 2)
+                                          (point-max))))))
+
+(ert-deftest test-ob-scheme/proper-list ()
+  "Test proper list output."
   (should
    (equal "- 1\n- 2\n- 3\n"
-         (org-test-with-temp-text "#+begin_src scheme :results list\n'(1 2 
3)\n#+end_src"
-           (org-babel-execute-maybe)
-           (let ((case-fold-search t)) (search-forward "#+results"))
-           (buffer-substring-no-properties (line-beginning-position 2)
-                                           (point-max))))))
+         (org-test-with-temp-text
+           "#+begin_src scheme :results list\n'(1 2 3)\n#+end_src"
+          (org-babel-execute-maybe)
+          (let ((case-fold-search t)) (search-forward "#+results"))
+          (buffer-substring-no-properties (line-beginning-position 2)
+                                          (point-max))))))
 
 (ert-deftest test-ob-scheme/list-conversion ()
   "Test list conversion from Scheme to Elisp."

Reply via email to