emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Doro Rose <doroerose@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH]: Fix ob-haskell.el to work with custom ghci prompts
Date: Sat, 02 Dec 2017 22:25:54 +0100	[thread overview]
Message-ID: <m17eu4kejh.fsf@gmail.com> (raw)
In-Reply-To: <87lgioomy9.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 29 Nov 2017 21:21:34 +0100")

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Fair enough. Could you provide a proper commit message and send the
> patch again?

Here's the patch.


[-- Attachment #2: ob-haskell.el patch --]
[-- Type: text/x-patch, Size: 2220 bytes --]

From 646d457f8d3e5d38084f44adfacf38a8cc762c30 Mon Sep 17 00:00:00 2001
From: louis <doro.rose@live.de>
Date: Sat, 2 Dec 2017 21:21:39 +0100
Subject: [PATCH] ob-haskell.el: Fix ob-haskell.el to work with custom ghci
 prompts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ob-haskell.el (haskell-prompt-regexp):  Define defvar
`haskell-prompt-regexp`.  This variable will override the variable set by
inf-haskell, when `org-babel-execute:haskell` is called.
(org-babel-execute:haskell):  Make sure that
`comint-prompt-regexp` is set appropriately to enable  correct parsing
of "λ"-prompts.  Set `comint-preoutput-filter-functions` appropriately to
enable correct parsing of coloured ghci prompts.

The problem was that code sent back from the inf-haskell buffer to
 org-babel wasn't parsed correctly in `org-babel-comint-with-output`.
 This occured when the user uses the commonly used "λ"-prompt.

TINYCHANGE
---
 lisp/ob-haskell.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
index cc78bec33..faf976b2d 100644
--- a/lisp/ob-haskell.el
+++ b/lisp/ob-haskell.el
@@ -59,14 +59,23 @@
 
 (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"")
 
+(defvar haskell-prompt-regexp)
+
 (defun org-babel-execute:haskell (body params)
   "Execute a block of Haskell code."
+  (require 'inf-haskell)
+  (add-hook 'inferior-haskell-hook
+            (lambda ()
+              (setq-local comint-prompt-regexp
+                          (concat haskell-prompt-regexp "\\|^λ?> "))))
   (let* ((session (cdr (assq :session params)))
          (result-type (cdr (assq :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params
 		     (org-babel-variable-assignments:haskell params)))
          (session (org-babel-haskell-initiate-session session params))
+       	 (comint-preoutput-filter-functions
+	       (cons 'ansi-color-filter-apply comint-preoutput-filter-functions))
          (raw (org-babel-comint-with-output
 		  (session org-babel-haskell-eoe t full-body)
                 (insert (org-trim full-body))
-- 
2.14.2


  reply	other threads:[~2017-12-02 21:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06  6:53 [PATCH]: Fix ob-haskell.el to work with custom ghci prompts Doro Rose
2017-11-16 21:04 ` Nicolas Goaziou
2017-11-16 22:22   ` Doro Rose
2017-11-17 22:14     ` Nicolas Goaziou
2017-11-18 11:12       ` Doro Rose
2017-11-29 20:21         ` Nicolas Goaziou
2017-12-02 21:25           ` Doro Rose [this message]
2017-12-11 14:14             ` Nicolas Goaziou

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=m17eu4kejh.fsf@gmail.com \
    --to=doroerose@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).