emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]: Fix ob-haskell.el to work with custom ghci prompts
@ 2017-11-06  6:53 Doro Rose
  2017-11-16 21:04 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Doro Rose @ 2017-11-06  6:53 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I noticed that ob-haskell.el doesn't support custom ghci prompts at present.
Custom ghci prompts such as "λ>" are quite popular in the haskell community, see for example

https://stackoverflow.com/questions/42081379/how-to-set-up-org-babel-for-haskell-with-stack

Could you have a look at the following patch and see, wether that would work in general, wrt. coding standars etc.
Obviously it works on my system, but I'm not an experienced elisp programmer, so I guess there might be  room for
improvement. 


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

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 @@
 
 (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))

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-11 14:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-12-11 14:14             ` Nicolas Goaziou

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).