tusharhero--- via "General discussions about Org-mode." <[email protected]> writes:
> To reproduce this, > > #+begin_src scheme > (cons 1 2) > #+end_src > > C-c C-c on this, > > You get 'Wrong type argument: listp, 2'. What about the attached patch? Rudy
>From 58e35f7e47af230bfa8c32382fe866030d579aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <[email protected]> Date: Sun, 16 Nov 2025 19:40:06 +0100 Subject: [PATCH] ob-scheme: Fix errors when the result is a cons cell * lisp/ob-scheme.el (org-babel-scheme--table-or-string): Fix Org Babel crashing with 'Wrong type argument: listp, 2' when the result is a cons cell. * 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 | 2 +- testing/lisp/test-ob-scheme.el | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el index 084d7b75e..68f0101a0 100644 --- a/lisp/ob-scheme.el +++ b/lisp/ob-scheme.el @@ -233,7 +233,7 @@ (defun org-babel-scheme--table-or-string (results) If the results look like a list or tuple, 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 ((listp res) + (cond ((proper-list-p res) (mapcar (lambda (el) (if (or (null el) (eq el 'null)) org-babel-scheme-null-to diff --git a/testing/lisp/test-ob-scheme.el b/testing/lisp/test-ob-scheme.el index 0fb79ad53..c4f1065c4 100644 --- a/testing/lisp/test-ob-scheme.el +++ b/testing/lisp/test-ob-scheme.el @@ -54,15 +54,27 @@ (ert-deftest test-ob-scheme/verbatim () (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/prologue () "Test :prologue parameter." -- 2.39.5 (Apple Git-154)
-- "It is not the strongest of the species that survives, not the most intelligent that survives. It is the one that is the most adaptable to change." --- Charles Darwin Rudolf Adamkovič <[email protected]> [he/him] http://adamkovic.org
