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=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