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

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

[elpa] externals/org d526ab5388 4/4: fixup! ob-python: Test and improve


From: ELPA Syncer
Subject: [elpa] externals/org d526ab5388 4/4: fixup! ob-python: Test and improve robustness for externally started python
Date: Fri, 29 Dec 2023 12:58:51 -0500 (EST)

branch: externals/org
commit d526ab538889f04afe7afcea6abafd20dc7fcfde
Author: Jack Kamm <jackkamm@gmail.com>
Commit: Jack Kamm <jackkamm@gmail.com>

    fixup! ob-python: Test and improve robustness for externally started python
    
    *
    lisp/ob-python.el (org-babel-python--python-util-comint-end-of-output-p):
    Backport python-util-comint-end-of-output-p for emacs28.
    (org-babel-python-initiate-session-by-key): Use backported version of
    python-util-comint-end-of-output-p.
---
 lisp/ob-python.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 8963d2f24c..6b3a608c8a 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -237,6 +237,15 @@ results as a string."
        (substring name 1 (- (length name) 1))
       name)))
 
+(defun org-babel-python--python-util-comint-end-of-output-p ()
+  "Return non-nil if the last prompt matches input prompt.
+Backport of `python-util-comint-end-of-output-p' to emacs28.  To
+be removed after minimum supported version reaches emacs29."
+  (when-let ((prompt (python-util-comint-last-prompt)))
+    (python-shell-comint-end-of-output-p
+     (buffer-substring-no-properties
+      (car prompt) (cdr prompt)))))
+
 (defvar-local org-babel-python--initialized nil
   "Flag used to mark that python session has been initialized.")
 (defun org-babel-python--setup-session ()
@@ -272,7 +281,7 @@ initialized session."
             (unless org-babel-python--initialized
               ;; Ensure first prompt. Based on python-tests.el
               ;; (`python-tests-shell-wait-for-prompt')
-              (while (not (python-util-comint-end-of-output-p))
+              (while (not 
(org-babel-python--python-util-comint-end-of-output-p))
                 (sit-for 0.1))
               (org-babel-python--setup-session))
           ;; Adding to `python-shell-first-prompt-hook' immediately



reply via email to

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