From: Igor Gajsin via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: emacs-orgmode@gnu.org
Subject: BUG: Org babel can't return a cons cell
Date: Tue, 04 Apr 2023 14:41:00 +0200 [thread overview]
Message-ID: <87bkk3x1bu.fsf@gajsin.name> (raw)
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 other threads:[~2023-04-06 16:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkk3x1bu.fsf@gajsin.name \
--to=emacs-orgmode@gnu.org \
--cc=igor@gajsin.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).