emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output


From: Kyle Meyer
Subject: Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output
Date: Wed, 20 May 2020 05:51:27 +0000

Nick Daly writes:

> Attached is an updated patch that makes output trimming work with
> blocks that do and don't produce results.  The old patch creates a
> =let: Wrong type argument: arrayp, nil= error when evaluating blocks
> that don't produce output.  This necessarily incorporates yesterday's
> patch.

Thanks for the patch.

> diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
> index bea162528..cb581fe3b 100644
> --- a/lisp/ob-haskell.el
> +++ b/lisp/ob-haskell.el
> @@ -83,12 +83,16 @@
>                         (cdr (member org-babel-haskell-eoe
>                                         (reverse (mapcar #'org-trim raw)))))))
>      (org-babel-reassemble-table
> -     (let ((result
> +     (let* ((result
>              (pcase result-type
>                (`output (mapconcat #'identity (reverse results) "\n"))
> -              (`value (car results)))))
> +              (`value (car results))))
> +            (result
> +             (if (stringp result)
> +                 (replace-regexp-in-string "Prelude[|>] " "" result)
> +               result)))

Oy, it's pretty nasty that those leak through.  I know ob-python (and
probably other languages) also suffers from similar brittleness.  It'd
be nice of course to figure out how to prevent the prompts leakage in
the first place, but, short of that, I think we should at least make the
regexp stricter so that it matches just the start of the string.

And that (stringp result) check is for the same reason as the one from
your first patch from yesterday which is now included ...

>         (org-babel-result-cond (cdr (assq :result-params params))
> -      result (org-babel-script-escape result)))
> +      result (if (stringp result) (org-babel-script-escape result))))

... here.  I believe result is nil in the problematic case, so this
could be

    (and result (org-babel-script-escape result))

However, based on stepping through the example in your patch from
yesterday, I think these two issues might be more closely related than
you realize.  In the

    (cdr (member org-babel-haskell-eoe
                 (reverse (mapcar #'org-trim raw))))

bit visible as a context line above, this is what I see for raw when I
step through org-babel-execute:haskell:

    ("Prelude| Prelude| Prelude| Prelude> \"org-babel-haskell-eoe\"" "")

So it looks like the member call above is returning nil because the
prompt markers are corrupting the element.  If that's the case, it seems
like the output cleansing should happen upstream of that call.

What do you think?



reply via email to

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