changeset 61037:758ff54158e2

(python-preoutput-leftover): New var. (python-preoutput-filter): Use it. (python-send-receive): Loop until all the result has been received.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 28 Mar 2005 14:36:25 +0000
parents e224865fdbb7
children f7f0c6eb075b
files lisp/ChangeLog lisp/progmodes/python.el
diffstat 2 files changed, 35 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Mar 28 03:17:53 2005 +0000
+++ b/lisp/ChangeLog	Mon Mar 28 14:36:25 2005 +0000
@@ -1,3 +1,9 @@
+2005-03-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/python.el (python-preoutput-leftover): New var.
+	(python-preoutput-filter): Use it.
+	(python-send-receive): Loop until all the result has been received.
+
 2005-03-28  Juri Linkov  <juri@jurta.org>
 
 	* dired.el (dired-mode-map): Add ellipsis to "Compare directories".
--- a/lisp/progmodes/python.el	Mon Mar 28 03:17:53 2005 +0000
+++ b/lisp/progmodes/python.el	Mon Mar 28 14:36:25 2005 +0000
@@ -1098,28 +1098,40 @@
 (defvar python-preoutput-continuation nil
   "If non-nil, funcall this when `python-preoutput-filter' sees `_emacs_ok'.")
 
+(defvar python-preoutput-leftover nil)
+
 ;; Using this stops us getting lines in the buffer like
 ;; >>> ... ... >>>
 ;; Also look for (and delete) an `_emacs_ok' string and call
 ;; `python-preoutput-continuation' if we get it.
 (defun python-preoutput-filter (s)
   "`comint-preoutput-filter-functions' function: ignore prompts not at bol."
+  (when python-preoutput-leftover
+    (setq s (concat python-preoutput-leftover s))
+    (setq python-preoutput-leftover nil))
   (cond ((and (string-match (rx (and string-start (repeat 3 (any ".>"))
-				     " " string-end))
-			    s)
-	      (/= (let ((inhibit-field-text-motion t))
-		    (line-beginning-position))
-		  (point)))
+                                     " " string-end))
+                            s)
+              (/= (let ((inhibit-field-text-motion t))
+                    (line-beginning-position))
+                  (point)))
+         "")
+        ((string= s "_emacs_ok\n")
+         (when python-preoutput-continuation
+           (funcall python-preoutput-continuation)
+           (setq python-preoutput-continuation nil))
+         "")
+        ((string-match "_emacs_out \\(.*\\)\n" s)
+         (setq python-preoutput-result (match-string 1 s))
+         "")
+	((string-match ".*\n" s)
+	 s)
+	((or (eq t (compare-strings s nil nil "_emacs_ok\n" nil (length s)))
+	     (eq t (compare-strings s nil nil "_emacs_out " nil
+				    (min (length "_emacs_out ") (length s)))))
+	 (setq python-preoutput-leftover s)
 	 "")
-	((string= s "_emacs_ok\n")
-	 (when python-preoutput-continuation
-	   (funcall python-preoutput-continuation)
-	   (setq python-preoutput-continuation nil))
-	 "")
-	((string-match "_emacs_out \\(.*\\)\n" s)
-	 (setq python-preoutput-result (match-string 1 s))
-	 "")
-	(t s)))
+        (t s)))
 
 ;;;###autoload
 (defun run-python (&optional cmd noshow)
@@ -1359,7 +1371,9 @@
   (let ((proc (python-proc)))
     (python-send-string string)
     (setq python-preoutput-result nil)
-    (accept-process-output proc 5)
+    (while (progn
+	     (accept-process-output proc 5)
+	     python-preoutput-leftover))
     python-preoutput-result))
 
 ;; Fixme: try to make it work with point in the arglist.  Also, is