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: Tue, 26 May 2020 00:05:30 +0000	[thread overview]
Message-ID: <87367nlfw5.fsf@kyleam.com> (raw)
In-Reply-To: <CAM-YhhC9EXUBq7-u1Rx=yamO6qf6mELrkqpPsEH=qpUKCyPZ5g@mail.gmail.com>

Nick Daly writes:

> On Sat, May 23, 2020 at 7:02 PM Nick Daly <nick.m.daly@gmail.com> 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.


  reply	other threads:[~2020-05-26  0:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 19:30 [PATCH] ob-haskell: Line Continuations Mangle Block Output Nick Daly
2020-05-17 20:07 ` Nick Daly
2020-05-20  5:51   ` Kyle Meyer
2020-05-24  0:02     ` Nick Daly
2020-05-24  2:46       ` Nick Daly
2020-05-26  0:05         ` Kyle Meyer [this message]
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=87367nlfw5.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nick.m.daly@gmail.com \
    /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 public 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).