[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add tests for ob-haskell (GHCi)

From: Ihor Radchenko
Subject: Re: [PATCH] Add tests for ob-haskell (GHCi)
Date: Wed, 22 Mar 2023 10:16:02 +0000

Bruno Barbier <brubar.cs@gmail.com> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>> From a first look, random failures appear to be related to session
>> initialization.
> My function 'test-ob-haskell-ghci' should protect against that; it
> ensures the "*haskell*" buffer is always new.  From what I understand,
> this is an input buffering problem: inputs are not full lines.

I see.

We can try the attached patch. Yet another edge case in comint, it

>From 2bdcec1e1f9a3ce0314d182a4c50887e8ec80a17 Mon Sep 17 00:00:00 2001
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 22 Mar 2023 11:12:30 +0100
Subject: [PATCH] org-babel-comint-with-output: Handle agglomerated prompts

* lisp/ob-comint.el (org-babel-comint-with-output): Consider that
comint can sometimes agglomerate multiple prompts together even within
a single output increment as passed to

Example in GHC comint buffer:

GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> ghci> :{
main :: IO ()
main = putStrLn "Hello World!"

ghci| ghci| ghci| ghci> ghci> Hello World!
ghci> "org-babel-haskell-eoe"
 lisp/ob-comint.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index 54bf5127e..e167d911b 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -91,7 +91,16 @@ (defmacro org-babel-comint-with-output (meta &rest body)
                               ;; trailing newline.  Use more reliable
                               ;; match to split the output later.
-                               comint-prompt-regexp
+                               ;; Sometimes, we get multiple agglomerated
+                               ;; prompts together in a single output:
+                               ;; "prompt prompt prompt output"
+                               ;; Remove them progressively, so that
+                               ;; possible "^" in the prompt regexp gets to
+                               ;; work as we remove the heading prompt
+                               ;; instance.
+                               (if (string-prefix-p "^" comint-prompt-regexp)
+                                   (format "^\\(%s\\)+" (substring 
comint-prompt-regexp 1))
+                                 comint-prompt-regexp)

>> It appears that ob-haskell is re-using sessions even
>> if :session is nil (default). And multiple session not allowed?? (I am
>> looking at `org-babel-haskell-initiate-session', which ignores session
>> parameter completely).
> From what I understood, the buffer "*haskell*" is coming from
> haskell-mode. And, to make it work might require some changes there too.

>From my reading of haskell-mode, it seems to be safe if we simply rename
Haskell process buffer upon session initialization.

Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]