all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Rudolf Adamkovič" <rudolf@adamkovic.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Is raw output from Common Lisp and Scheme broken?
Date: Sat, 10 Aug 2024 14:19:37 +0000	[thread overview]
Message-ID: <875xs831fq.fsf@localhost> (raw)
In-Reply-To: <m2le17cn7n.fsf@adamkovic.org>

Rudolf Adamkovič <rudolf@adamkovic.org> writes:

> I would like to output
>
>   raw Org/LaTeX from Common Lisp and Scheme
>
> but it does not seem to work:
>
> EMACS LISP - ALL OK:
> ...
> LUA - ALL OK:
> ...
> COMMON LISP - *NOT* OK:
>
> (1) DOUBLE BACKSLASHES

You can "print" it to format to make things work.

Currently, ob-lisp simply does (org-strip-quotes result) in contrast to

(if (or (member "scalar" result-params)
                (member "verbatim" result-params))
            (format "%S" result)
          (format "%s" result))

in ob-emacs-lisp.

However, I am not sure if Elisp version of `format' can correctly
unquote Lisp strings.

> (2) RESULTS GROW

That's expected for raw output - Org is unable to know the result
boundaries in such scenario.

> SCHEME - *NOT* OK:
>
> (1) SUPERFLUOUS QUOTES
> (2) DOUBLE BACKSLASHES
> (3) RESULTS GROW
>
>   #+BEGIN_SRC scheme :results raw
>   "\\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}"
>   #+END_SRC
>   
>   #+RESULTS:
>   "\\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}"

This is technically the actual value returned by scheme, but we indeed
do format the returned strings for Lua and Elisp.

You can try

#+begin_src scheme :results raw output
(display "\\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}")
#+end_src

#+RESULTS:
\begin{array}{cc|cc} 1 & 2 & 3 & 4\end{array}

> Is escaping and quoting broken for Common Lisp and Scheme, ...
>
> ... or am I using something incorrectly?

It is broken.
We should use Lisp/Scheme equivalents of `format' to solve the problem.
Something akin `org-babel-lua-wrapper-method'.
Patches welcome!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


      reply	other threads:[~2024-08-10 14:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08 10:39 Is raw output from Common Lisp and Scheme broken? Rudolf Adamkovič
2024-08-10 14:19 ` Ihor Radchenko [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xs831fq.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=rudolf@adamkovic.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.