emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Nick Daly <nick.m.daly@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output
Date: Wed, 20 May 2020 05:51:27 +0000	[thread overview]
Message-ID: <87o8qjduhs.fsf@kyleam.com> (raw)
In-Reply-To: <CAM-YhhD09NR1qXntX4Jd8o=+eui+DXgPqu+Nh1t04sFD4iMJJQ@mail.gmail.com>

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	other threads:[~2020-05-20  5:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 19:30 Nick Daly
2020-05-17 20:07 ` Nick Daly
2020-05-20  5:51   ` Kyle Meyer [this message]
2020-05-24  0:02     ` Nick Daly
2020-05-24  2:46       ` Nick Daly
2020-05-26  0:05         ` Kyle Meyer
2020-05-31 17:00           ` Nick Daly
2020-05-26  0:02       ` Kyle Meyer

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=87o8qjduhs.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nick.m.daly@gmail.com \
    --subject='Re: [PATCH] ob-haskell: Line Continuations Mangle Block Output' \
    /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

Code repositories for project(s) associated with this 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).