 	  (if (or (search-forward ">>> " current t)
 		  (search-forward "... " current t))
 	      (comint-send-input)
-	    (let ()
-	     (goto-char current)
-	     (comint-interrupt-subjob))))
-      (comint-send-input))))
-
-
-;; Function to try to resume panda mainloop
-(defun python-resume ()
-  (interactive)
-  (let* ((curbuf (current-buffer))
-	(proc (get-process py-which-bufname))
-	(procbuf (process-buffer proc))
-	)
-    (set-buffer procbuf)
-    (insert "run()\n")
-    (py-execute-string "try:\n\trun()\nexcept NameError,e:\n\tif e.__str__() == 'run':\n\t\tpass\n\telse:\n\t\traise\nexcept:\n\traise")
-    (goto-char (point-max))
-    (set-buffer curbuf)
+	    (save-current-buffer
+	      (goto-char current)
+	      (for-all-py-procs
+	       (lambda (proc)
+		 (let ((procbuf (process-buffer proc)))
+		   (set-buffer procbuf)
+		   (goto-char (point-max))
+		   (if (and (eobp) proc (= (point) (marker-position (process-mark proc))))
+		       (comint-interrupt-subjob))
+		   )
+		 )
+	       ))
+	    )
+	  )
+      (comint-send-input)
+      )
     )
   )
 
+(defun py-point-to-max (proc)
+  ;; updates the cursor position of a buffer for all windows
+  ;; into that buffer
+  (save-current-buffer
+    (let ((procbuf (process-buffer proc)))
+      (mapcar (lambda (window)
+		(set-window-point window (point-max)))
+	      (get-buffer-window-list procbuf))
+      (set-buffer procbuf)
+      (goto-char (point-max))
+      )
+    )
+  )
+
+;; Function to try to resume panda mainloop
+(defun python-resume (proc)
+  (interactive)
+  (save-current-buffer
+    (let ((procbuf (process-buffer proc))
+	  )
+      (set-buffer procbuf)
+      (goto-char (point-max))
+      (insert "run()\n")
+      (py-execute-string "try:\n\trun()\nexcept NameError,e:\n\tif e.__str__() == 'run':\n\t\tpass\n\telse:\n\t\traise\nexcept:\n\traise" proc)
+      (py-point-to-max proc)
+    ))
+  )
 
 
 (defun py-redefine-class (&optional async)
   (interactive "P")
   (save-excursion
-      (py-mark-def-or-class t)
-      ;; mark is before point
-      (py-redefine-class-region (mark) (point) async)
-      )
+    (py-mark-def-or-class t)
+    ;; mark is before point
+    (py-redefine-class-region (mark) (point) async)
+    )
   )
 
 
-(defun py-redefine-class-region (start end &optional async)
+(defun py-redefine-class-region-for-proc (start end proc)
   (interactive "r\nP")
-  (or (< start end)
-      (error "Region is empty"))
-  (let* ((proc (get-process py-which-bufname))
-	 (temp (if (memq 'broken-temp-names py-emacs-features)
+  (let* ((temp (if (memq 'broken-temp-names py-emacs-features)
 		   (let
 		       ((sn py-serial-number)
 			(pid (and (fboundp 'emacs-pid) (emacs-pid))))


    \t## working on region in file <name>...

is inserted at the end.  See also the command `py-clear-queue'."
  (interactive "r\nP")
  (or (< start end)
      (error "Region is empty"))
  (let* ((proc (get-process py-which-bufname))
	 (temp (if (memq 'broken-temp-names py-emacs-features)
		   (let
		       ((sn py-serial-number)

    (message "Using the %s shell" msg)
    (setq py-output-buffer (format "*%s Output*" py-which-bufname))))

(defun py-kill-shells ()
  (interactive)
  (save-current-buffer
    (for-all-py-procs
     (lambda (proc)
       (let ((procbuf (process-buffer proc)))
	 (set-buffer procbuf)
	 (comint-send-eof)
	 (py-point-to-max proc)
	 )
       )
     )
    )
  )

;;;###autoload
(defun py-shell (&optional argprompt)
  "Start an interactive Python interpreter in another window.
