 (defun slate-inf-filter (process string)
   "Make sure that the window continues to show the most recently output
 text."
-  (let ((where 0) ch command-str)
-    (while (and string where)
-      (when slate-output-buffer
-	(setq string (slate-accum-command string)))
-      (when (and string
-		 (setq where (string-match "\C-a\\|\C-b" string)))
-	(setq ch (aref string where))
-	(cond ((= ch ?\C-a)		;strip these out
-	       (setq string (concat (substring string 0 where)
-				    (substring string (1+ where)))))
-	      ((= ch ?\C-b)		;start of command
-	       (setq slate-output-buffer "") ;start this off
-	       (setq string (substring string (1+ where)))))))
-    (save-excursion
-      (set-buffer (process-buffer process))
-      (goto-char (point-max))
-      (when string
-	(setq mode-status "Idle")
-	(insert string))
-      ; Handle most recent debugger output:
-      (save-excursion
-	(goto-char (point-max))
-	(re-search-backward "^Debugging: " nil t)
-        ; Handle debugger file references:
+  (with-current-buffer (process-buffer process)
+    (when (buffer-name (current-buffer))
+      (let ((where 0) ch command-str
+	    (moving (= (point) (process-mark process))))
+	(while (and string where)
+	  (when slate-output-buffer
+	    (setq string (slate-accum-command string)))
+	  (when (and string
+		     (setq where (string-match "\C-a\\|\C-b" string)))
+	    (setq ch (aref string where))
+	    (cond ((= ch ?\C-a)		;strip these out
+		   (setq string (concat (substring string 0 where)
+					(substring string (1+ where)))))
+		  ((= ch ?\C-b)		       ;start of command
+		   (setq slate-output-buffer "") ;start this off
+		   (setq string (substring string (1+ where)))))))
 	(save-excursion
-	  (let (fileref-end)
-	    (while (setq fileref-end (re-search-forward slate-debug-fileref-regexp nil t))
-	      (let ((fileref-overlay (slate-overlay (match-beginning 1) fileref-end 'link 'highlight nil "mouse-1: visit this file and line")))
-		(overlay-put fileref-overlay 'keymap slate-fileref-keymap)))))
-        ; Handle debugger frame references:
-	(while (re-search-forward slate-debug-frame-regexp nil t)
-	  (let ((frameref-overlay (slate-overlay (match-beginning 1) (match-end 1) 'button nil nil "mouse-1: navigate to this frame")))
-	    (overlay-put frameref-overlay 'keymap slate-frameref-keymap)))
-	; Handle debugger restart listing:
-	(let (restart-end)
-	  (while (setq restart-end (re-search-forward slate-debug-restart-regexp nil t))
-	    (let ((restart-overlay (slate-overlay (match-beginning 0) restart-end 'button nil nil "mouse-1: select this restart")))
-	      (overlay-put restart-overlay 'keymap slate-restart-keymap)))))
-      (when (process-mark process)
-	(set-marker (process-mark process) (point-max)))))
-  (let ((buf (current-buffer)))
-    (set-buffer (process-buffer process))
-    (goto-char (point-max)) (sit-for 0)
-    (set-window-point (get-buffer-window (current-buffer)) (point-max))
-    (set-buffer buf)))
+	  (goto-char (point-max))
+	  (when string
+	    (setq mode-status "Idle")
+	    (insert string))
+	  (save-excursion	 ; Handle most recent debugger output:
+	    (goto-char (point-max))
+	    (re-search-backward "^Debugging: " nil t)
+	    (save-excursion	    ; Handle debugger file references:
+	      (let (fileref-end)
+		(while (setq fileref-end (re-search-forward slate-debug-fileref-regexp nil t))
+		  (let ((fileref-overlay (slate-overlay (match-beginning 1) fileref-end 'link 'highlight nil "mouse-1: visit this file and line")))
+		    (overlay-put fileref-overlay 'keymap slate-fileref-keymap)))))
+					; Handle debugger frame references:
+	    (while (re-search-forward slate-debug-frame-regexp nil t)
+	      (let ((frameref-overlay (slate-overlay (match-beginning 1) (match-end 1) 'button nil nil "mouse-1: navigate to this frame")))
+		(overlay-put frameref-overlay 'keymap slate-frameref-keymap)))
+					; Handle debugger restart listing:
+	    (let (restart-end)
+	      (while (setq restart-end (re-search-forward slate-debug-restart-regexp nil t))
+		(let ((restart-overlay (slate-overlay (match-beginning 0) restart-end 'button nil nil "mouse-1: select this restart")))
+		  (overlay-put restart-overlay 'keymap slate-restart-keymap)))))
+	  (when (process-mark process)
+	    (set-marker (process-mark process) (point-max))))
+	(if moving (goto-char (process-mark process)))
+	(sit-for 0)
+	(set-window-point (get-buffer-window (current-buffer)) (point-max))))))
+
+(defun slate-inf-filter-redirect (process string)
+  )
 
 (defvar slate-interactor-mode-map
   (let ((map (copy-keymap slate-mode-map)))

				    (overlay-end first-overlay))))
    (goto-char (point-max))
    (insert code)
    (comint-send-string inferior-slate-buffer-name (concat code ".\n"))))

(defun slate-follow-name-at-point ()
  "Follows a file reference of the form filename:linenumber at/after the point."

  "Performs `slate-eval-region' on the current region and inserts the output
into the current buffer after the cursor."
  (interactive "r")
  (slate-ensure-running)
  (set-process-filter *slate-process*
		      (lambda (proc string) (insert string)))
  (save-excursion
    (goto-char end)
    (slate-backward-whitespace)
    (slate-send-input (buffer-substring-no-properties start (point)) t)
    (accept-process-output *slate-process*))
  (set-process-filter *slate-process* 'slate-inf-filter))

(defun slate-quit ()
