From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doro Rose Subject: Re: [PATCH]: Fix ob-haskell.el to work with custom ghci prompts Date: Sat, 02 Dec 2017 22:25:54 +0100 Message-ID: References: <87k1yque93.fsf@nicolasgoaziou.fr> <87y3n4tuvy.fsf@nicolasgoaziou.fr> <87lgioomy9.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLFIX-0006AI-6R for emacs-orgmode@gnu.org; Sat, 02 Dec 2017 16:26:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLFIT-0005yH-3h for emacs-orgmode@gnu.org; Sat, 02 Dec 2017 16:26:09 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:35819) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eLFIS-0005wV-Ql for emacs-orgmode@gnu.org; Sat, 02 Dec 2017 16:26:05 -0500 Received: by mail-wm0-x234.google.com with SMTP id f9so8536309wmh.0 for ; Sat, 02 Dec 2017 13:26:04 -0800 (PST) In-Reply-To: <87lgioomy9.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 29 Nov 2017 21:21:34 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Nicolas Goaziou writes: > Fair enough. Could you provide a proper commit message and send the > patch again? Here's the patch. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-ob-haskell.el-Fix-ob-haskell.el-to-work-with-custom-.patch Content-Transfer-Encoding: quoted-printable Content-Description: ob-haskell.el patch >From 646d457f8d3e5d38084f44adfacf38a8cc762c30 Mon Sep 17 00:00:00 2001 From: louis 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=3DUTF-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 "=CE=BB"-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 "=CE=BB"-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 @@ =20 (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"") =20 +(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 "\\|^=CE=BB?> ")))) (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)) --=20 2.14.2 --=-=-=--