emacs-orgmode
[Top][All Lists]
Advanced

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

BUG: Org babel can't return a cons cell


From: Igor Gajsin
Subject: BUG: Org babel can't return a cons cell
Date: Tue, 04 Apr 2023 14:41:00 +0200

Hello,
I've found a bug in org-babel. The simple code

#+begin_src scheme
  (cons 1 2)
#+end_src

Produces an error:

#+begin_quote
Debugger entered--Lisp error: (wrong-type-argument listp 2)
  org-babel-scheme--table-or-string("(1 . 2)")
  org-babel-execute:scheme("(cons 1 2)" ((:colname-names) (:rowname-names) 
(:result-params "replace") (:result-type . value) (:results . "replace") 
(:exports . "code") (:session . "none") (:cache . "no") (:noweb . "no") 
(:hlines . "no") (:tangle . "no")))
  org-babel-execute-src-block(nil ("scheme" "(cons 1 2)" ((:colname-names) 
(:rowname-names) (:result-params "replace") (:result-type . value) (:results . 
"replace") (:exports . "code") (:tangle . "no") (:hlines . "no") (:noweb . 
"no") (:cache . "no") (:session . "none")) "" nil 203 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)
#+end_quote

There is a fix I've found (thanks yantar92Orgcontr from
#org-mode@libera.chat)

#+begin_src elisp
(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."
  (let ((res (and results (org-babel-script-escape results))))
    (cond ((proper-list-p res)
           (mapcar (lambda (el)
                     (if (or (null el) (eq el 'null))
                         org-babel-scheme-null-to
                       el))
                   res))
          (t res))))
#+end_src

should work on emacs older then Emacs 26 (proper-list-p not implemented here).

--
With best regards,
Igor Gajsin



reply via email to

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