[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: |
Tue, 26 May 2020 00:05:30 +0000 |
Nick Daly writes:
> On Sat, May 23, 2020 at 7:02 PM Nick Daly <address@hidden> wrote:
>> : "^\\*?[[:upper:]][\\._[:alnum:]]*\\(?:
>> \\*?[[:upper:]][\\._[:alnum:]]*\\)*\\( λ\\)?> "
>>
>> =comint-prompt-regexp='s variable documentation calls out much simpler
>> regexps
>>
>> : "^[^>]+\\(> \\)?"
>
> This simplified patch breaks one case that I'd forgotten about: the
> true one-liner, where the output displays before the "Prelude> "
> prompt even appears.
>
> #+BEGIN_SRC haskell
> [... several examples ... ]
Thanks for the nice examples. It'd be great to eventually include at
least some of them as tests.
> diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
> index bea162528..6ac34f2f5 100644
> --- a/lisp/ob-haskell.el
> +++ b/lisp/ob-haskell.el
> @@ -56,15 +56,27 @@
For the next iteration, could you send a patch generated by
git-format-patch? See <https://orgmode.org/worg/org-contribute.html>.
Please also consider signing copyright papers, but I suspect the
ob-haskell.el changes will end up being few enough lines that they can
be accepted as a TINYCHANGE.
> (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"")
>
> -(defvar haskell-prompt-regexp)
> +(defvar haskell-prompt-regexp "^\\(\\*?[[:upper:]][\\._[:alnum:]]*\\(?:
> \\*?[[:upper:]][\\._[:alnum:]]*\\)*\\( λ\\)?[|>] \\)*"
> + "Filter out prompts from Haskell interpreters:
> +
> +GHC:
> +
> +- 'output
> + ^Prelude> EOE'
> +- '^Prelude> output EOE'
> +- '^Prelude| Prelude| Prelude> output EOE'
> +
> +Unknown Interpreter:
> +
> +- '^> '
> +- '^λ> '")
This is inf-haskell's variable. ob-haskell shouldn't set it. The
original (defvar haskell-prompt-regexp) just silenced the bytecompiler.
If ob-haskell needs to tweak comint-prompt-regexp to deal with the
"^Prelude| Prelude| Prelude" above, it should done without overwriting
an inf-haskell value.
As touched on in my other email, there's also the issue of compatibility
with versions of haskell mode before v17.1 that lack a
haskell-prompt-regexp. I believe this is why you're seeing the
undefined errors.
So, I dunno. I'm not a ob-haskell user or a really a Babel user. But
in my view it'd be cleaner to just leave inferior-haskell-mode's
comint-prompt-regexp alone and strip the "Prelude| Prelude| ..." once
the output comes out of org-babel-comint-with-output. It's hacky and
error-prone, but I don't think it's so different than what
org-babel-comint-with-output already does.