From: Ihor Radchenko <yantar92@posteo.net>
To: Bruno Barbier <brubar.cs@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Add tests for ob-haskell (GHCi)
Date: Wed, 22 Mar 2023 10:16:02 +0000 [thread overview]
Message-ID: <87h6udozvh.fsf@localhost> (raw)
In-Reply-To: <6416e4d9.df0a0220.ce03d.5c4b@mx.google.com>
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
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
appears.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-babel-comint-with-output-Handle-agglomerated-pro.patch --]
[-- Type: text/x-patch, Size: 2215 bytes --]
From 2bdcec1e1f9a3ce0314d182a4c50887e8ec80a17 Mon Sep 17 00:00:00 2001
Message-Id: <2bdcec1e1f9a3ce0314d182a4c50887e8ec80a17.1679480064.git.yantar92@posteo.net>
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
better
* 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
`comint-output-filter-functions'.
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!"
:}
main
"org-babel-haskell-eoe"
ghci| ghci| ghci| ghci> ghci> Hello World!
ghci> "org-babel-haskell-eoe"
ghci>
---
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.
(replace-regexp-in-string
- 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)
,org-babel-comint-prompt-separator
text))))
comint-output-filter-functions))
--
2.39.1
[-- Attachment #3: Type: text/plain, Size: 722 bytes --]
>> 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>
next prev parent reply other threads:[~2023-03-22 10:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-19 9:12 [PATCH] Add tests for ob-haskell (GHCi) Bruno Barbier
2023-03-19 10:20 ` Ihor Radchenko
2023-03-19 10:28 ` Ihor Radchenko
2023-03-19 10:32 ` Bruno Barbier
2023-03-22 10:16 ` Ihor Radchenko [this message]
2023-03-24 10:36 ` Ihor Radchenko
2023-03-25 10:01 ` Bruno Barbier
2023-03-26 9:09 ` Ihor Radchenko
2023-03-26 9:40 ` Bruno Barbier
2023-03-26 9:46 ` Ihor Radchenko
[not found] ` <notmuch-sha1-0807e1720f829950d42ef560bc30e56bd152766c>
2023-05-07 8:50 ` Bruno Barbier
2023-05-07 9:18 ` Ruijie Yu via General discussions about Org-mode.
2023-05-07 11:15 ` Bruno Barbier
2023-05-08 10:59 ` Ihor Radchenko
2023-05-21 7:40 ` Bruno Barbier
2023-06-02 8:44 ` Ihor Radchenko
2023-08-10 12:51 ` Ihor Radchenko
2023-08-25 19:10 ` Bruno Barbier
2023-09-07 14:21 ` Bruno Barbier
2023-09-08 8:23 ` Ihor Radchenko
2023-09-08 9:49 ` Bruno Barbier
2023-03-23 10:35 ` Ihor Radchenko
2023-03-23 21:01 ` ParetoOptimalDev
2023-03-23 21:30 ` ParetoOptimalDev
2023-03-24 10:40 ` Ihor Radchenko
2023-03-26 3:27 ` ParetoOptimalDev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6udozvh.fsf@localhost \
--to=yantar92@posteo.net \
--cc=brubar.cs@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).