From 12566797d3f622212d165bb1d11df335e295dc4a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 28 Mar 2005 14:36:25 +0000 Subject: (python-preoutput-leftover): New var. (python-preoutput-filter): Use it. (python-send-receive): Loop until all the result has been received. --- lisp/progmodes/python.el | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 20af0aaf96e..10845b23630 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1098,28 +1098,40 @@ Don't save anything for STR matching `inferior-python-filter-regexp'." (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= 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-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) "") - (t s))) + (t s))) ;;;###autoload (defun run-python (&optional cmd noshow) @@ -1359,7 +1371,9 @@ The result is what follows `_emacs_out' in the output (or nil)." (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 -- cgit v1.2.1 From 9f3f6a1854cfb2baad2cd5729432dcf36a9a0dcc Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 29 Mar 2005 14:12:23 +0000 Subject: (python-preoutput-filter): Fix last change. --- lisp/progmodes/python.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 10845b23630..5073f2bc23a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1127,8 +1127,8 @@ Don't save anything for STR matching `inferior-python-filter-regexp'." ((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))))) + (let ((end (min (length "_emacs_out ") (length s)))) + (eq t (compare-strings s nil end "_emacs_out " nil end)))) (setq python-preoutput-leftover s) "") (t s))) -- cgit v1.2.1