0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 19:02:52 +00:00

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>
This commit is contained in:
Ihor Radchenko 2023-03-22 11:12:30 +01:00
parent f9bbc79d62
commit 7fa9e9a4b3
No known key found for this signature in database
GPG key ID: 6470762A7DA11D8B

View file

@ -91,7 +91,16 @@ or user `keyboard-quit' during execution of 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))