* BUG: Org babel can't return a cons cell
@ 2023-04-04 12:41 Igor Gajsin via General discussions about Org-mode.
0 siblings, 0 replies; only message in thread
From: Igor Gajsin via General discussions about Org-mode. @ 2023-04-04 12:41 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 16:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04 12:41 BUG: Org babel can't return a cons cell Igor Gajsin via General discussions about Org-mode.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).