> Curiouser and curiouser. I put a message in > python-preoutput-filter that echoes its parameter as you > suggest. Looking at the contents of my messages buffer after > attempting the completion for "os.", the "Can't find completion" > message from the python completion routine happens after > precisely 1024 characters are read. Furthermore it looks like the > data coming from the process is interrupted every 1024 > characters.
Oh, I think I know what's happening. Can you try the patch below? I haven't been able to really test it because in my case the input string is always just one complete line, so the looping and the python-preoutput-leftover aren't used. Stefan --- orig/lisp/progmodes/python.el +++ mod/lisp/progmodes/python.el @@ -1098,28 +1098,46 @@ (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." - (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)) - "") - (t s))) + (when python-preoutput-leftover + (setq s (concat python-preoutput-leftover s)) + (setq python-preoutput-leftover nil)) + (let ((res "")) + (while (> (length s) 0) + (cond ((and (string-match (rx (and string-start (repeat 3 (any ".>")) + " " string-end)) + s) + (/= (let ((inhibit-field-text-motion t)) + (line-beginning-position)) + (point))) + (setq s nil)) + ((string-match "\\`_emacs_ok\n" s) + (setq s (substring s (match-end 0))) + (when python-preoutput-continuation + (funcall python-preoutput-continuation) + (setq python-preoutput-continuation nil))) + ((string-match "\\`_emacs_out \\(.*\\)\n?" s) + (setq python-preoutput-result + (concat python-preoutput-result (match-string 1 s))) + (setq s (substring s (match-end 0))) + (if (/= (match-end 1) (match-end 0)) + (set (make-local-variable 'python-preoutput-leftover) + "_emacs_out "))) + ((or (eq t (compare-strings s nil nil "_emacs_ok\n" nil (length s))) + (eq t (compare-strings s nil nil "_emacs_out " nil (length s)))) + (set (make-local-variable 'python-preoutput-leftover) s) + (setq s nil)) + ((string-match "\\`.*\n?" s) + (setq res (concat res (match-string 0 s))) + (setq s (substring s (match-end 0)))))) + res)) ;;;###autoload (defun run-python (&optional cmd noshow) _______________________________________________ Emacs-pretest-bug mailing list Emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug