From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doro Rose Subject: [PATCH]: Fix ob-haskell.el to work with custom ghci prompts Date: Mon, 06 Nov 2017 07:53:58 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBbIR-0005bG-3S for emacs-orgmode@gnu.org; Mon, 06 Nov 2017 01:54:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBbIM-0000yD-8T for emacs-orgmode@gnu.org; Mon, 06 Nov 2017 01:54:11 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:46893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBbIM-0000wq-0Q for emacs-orgmode@gnu.org; Mon, 06 Nov 2017 01:54:06 -0500 Received: by mail-wm0-x232.google.com with SMTP id r68so11539114wmr.1 for ; Sun, 05 Nov 2017 22:54:05 -0800 (PST) Received: from Doros-MBP (ipservice-092-211-140-182.092.211.pools.vodafone-ip.de. [92.211.140.182]) by smtp.gmail.com with ESMTPSA id q12sm10727339edj.29.2017.11.05.22.54.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Nov 2017 22:54:03 -0800 (PST) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I noticed that ob-haskell.el doesn't support custom ghci prompts at present. Custom ghci prompts such as "=CE=BB>" are quite popular in the haskell comm= unity, see for example https://stackoverflow.com/questions/42081379/how-to-set-up-org-babel-for-ha= skell-with-stack Could you have a look at the following patch and see, wether that would wor= k in general, wrt. coding standars etc. Obviously it works on my system, but I'm not an experienced elisp programme= r, so I guess there might be room for improvement.=20 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=ob-haskell.el.diff Content-Transfer-Encoding: quoted-printable Content-Description: ob-haskell.el diff diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index cc78bec33..361b2b9ce 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)) --=-=-=--