emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org a8a516ba33: org-babel-comint-with-output: Handle ag


From: ELPA Syncer
Subject: [elpa] externals/org a8a516ba33: org-babel-comint-with-output: Handle agglomerated prompts better
Date: Fri, 24 Mar 2023 06:05:17 -0400 (EDT)

branch: externals/org
commit a8a516ba330fe8c435334030ffbe371b8c80c877
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    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 86c2bf7a76..7b51716429 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -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))



reply via email to

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