all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: python-mode: make sure output is not eaten
Date: Tue, 22 Aug 2006 02:10:02 -0400	[thread overview]
Message-ID: <87lkphe20n.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20060821220052.494C.SLAWOMIR.NOWACZYK.847@student.lu.se> (Slawomir Nowaczyk's message of "Mon, 21 Aug 2006 22:16:56 +0200")

> the following path makes sure python-mode doesn't eat output coming
> from the Python process. Without it, calling python-send-buffer on
> a Python script which produces output, such as simple

Does the patch below give good results as well?


        Stefan


--- python.el	20 aoû 2006 14:13:46 -0400	1.41
+++ python.el	22 aoû 2006 02:08:00 -0400	
@@ -1264,9 +1264,25 @@
   (when python-preoutput-leftover
     (setq s (concat python-preoutput-leftover s))
     (setq python-preoutput-leftover nil))
+  (let ((start 0)
+        (res ""))
+    ;; First process whole lines.
+    (while (string-match "\n" s start)
+      (let ((line (substring s start (setq start (match-end 0)))))
+        (cond
+         ((string= line "_emacs_ok\n")
+          (when python-preoutput-continuation
+            (funcall python-preoutput-continuation)
+            (setq python-preoutput-continuation nil)))
+         ((string-match "\\`_emacs_out \\(.*\\)\n" line)
+          (setq python-preoutput-result (match-string 1 line)))
+         (t (setq res (concat res line))))))
+    ;; Then process the remaining partial line.
+    (unless (zerop start) (setq s (substring s start)))
   (cond ((and (string-match (rx string-start (repeat 3 (any ".>"))
 				" " string-end)
-                            s)
+                              s start)
+                ;; Isn't that just (not (bolp)) ?  --Stef
               (/= (let ((inhibit-field-text-motion t))
                     (line-beginning-position))
                   (point)))
@@ -1274,23 +1290,14 @@
          ;; What is this all about, exactly?  --Stef
 	 ;; (if (and (eq ?. (aref s 0)))
 	 ;;     (accept-process-output (get-buffer-process (current-buffer)) 1))
-         "")
-        ((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)
+           ;; Throw away this prompt-like thingy.
+           res)
 	((or (eq t (compare-strings s nil nil "_emacs_ok\n" nil (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)))
+	 res)
+        (t (concat res s)))))
 
 (autoload 'comint-check-proc "comint")
 

  reply	other threads:[~2006-08-22  6:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-21 20:16 python-mode: make sure output is not eaten Slawomir Nowaczyk
2006-08-22  6:10 ` Stefan Monnier [this message]
2006-08-22 18:26   ` Slawomir Nowaczyk
2006-08-23  4:04     ` Stefan Monnier
2006-08-25  0:18       ` Steven Huwig
2006-08-25  0:34         ` Steven Huwig
2006-08-25  1:29         ` Steven Huwig
2006-08-25  9:03         ` Slawomir Nowaczyk
2006-08-25 19:53         ` Ken Manheimer
2006-08-25 20:10           ` Stefan Monnier
2006-08-25  9:03       ` Slawomir Nowaczyk
2006-08-25 22:53         ` Stefan Monnier
2006-08-26 12:41           ` Slawomir Nowaczyk
2006-08-26 14:48             ` Stefan Monnier
2006-08-26 22:22               ` Slawomir Nowaczyk
2006-08-28 21:43                 ` Stefan Monnier
2006-08-30 21:08                   ` Slawomir Nowaczyk
2006-08-30 22:10                     ` Stefan Monnier
2006-08-31 11:19                       ` Slawomir Nowaczyk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lkphe20n.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.