emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: OS X python.el completion issue


From: Steven Huwig
Subject: Re: OS X python.el completion issue
Date: Sun, 27 Mar 2005 01:55:47 -0500


On Mar 26, 2005, at 8:05 PM, Stefan Monnier wrote:

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.


I couldn't get your patch to work. However, I did see what was going on
and I managed to write my own patch. I don't know if this could break
anything else, but it does fix my OS X completion problems.

From my limited knowledge, it looks as if the process communication
code for OS X will return data in 1024-character blocks, but for
better-supported platforms, it will read until the end of line?

Thanks,
Steven Huwig

--- python.el   9 Feb 2005 15:50:36 -0000       1.24
+++ python.el   27 Mar 2005 06:48:31 -0000
@@ -1098,6 +1098,8 @@
 (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
@@ -1105,21 +1107,33 @@
 (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)))
+                                     " " 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 "_emacs_out \\(.*\\)" s)
+         (setq python-preoutput-leftover (match-string 1 s))
+         "")
+        ((> (length python-preoutput-leftover) 0)
+         (cond
+          ((string-match "\\(.*\\)\n" s)
+           (setq python-preoutput-result
+                 (concat python-preoutput-leftover (match-string 1 s)))
+           (setq python-preoutput-leftover nil))
+          (t (setq python-preoutput-leftover
+                   (concat python-preoutput-leftover s))))
+         "")
+        (t s)))

 ;;;###autoload
 (defun run-python (&optional cmd noshow)
@@ -1360,6 +1374,8 @@
     (python-send-string string)
     (setq python-preoutput-result nil)
     (accept-process-output proc 5)
+    (while (> (length python-preoutput-leftover) 0)
+      (accept-process-output proc 5))
     python-preoutput-result))

 ;; Fixme: try to make it work with point in the arglist.  Also, is





reply via email to

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