all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is raw output from Common Lisp and Scheme broken?
@ 2024-08-08 10:39 Rudolf Adamkovič
  2024-08-10 14:19 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Rudolf Adamkovič @ 2024-08-08 10:39 UTC (permalink / raw)
  To: emacs-orgmode

Howdy!

I would like to output

  raw Org/LaTeX from Common Lisp and Scheme

but it does not seem to work:

EMACS LISP - ALL OK:

  #+BEGIN_SRC elisp :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}

LUA - ALL OK:

  #+BEGIN_SRC lua :results raw
  return "\\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}"
  #+END_SRC
  
  #+RESULTS:
  \begin{array}{cc|cc} 1 & 2 & 3 & 4\end{array}

COMMON LISP - *NOT* OK:

(1) DOUBLE BACKSLASHES
(2) RESULTS GROW

  #+BEGIN_SRC lisp :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}
  \\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}
  \\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}

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}"
  "\\begin{array}{cc|cc} 1 & 2 & 3 & 4\\end{array}"
  "\\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?

Thank you!

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
--- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is raw output from Common Lisp and Scheme broken?
  2024-08-08 10:39 Is raw output from Common Lisp and Scheme broken? Rudolf Adamkovič
@ 2024-08-10 14:19 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-08-10 14:19 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

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>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-10 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08 10:39 Is raw output from Common Lisp and Scheme broken? Rudolf Adamkovič
2024-08-10 14:19 ` Ihor Radchenko

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.