Index: /branches/event-ide/ccl/cocoa-ide/cocoa-editor.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/cocoa-editor.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/cocoa-editor.lisp	(revision 7929)
@@ -766,8 +766,4 @@
                 (slot-value hemlock-string 'cache) nil
                 (hi::buffer-document buffer) nil)
-          (let* ((p (hi::buffer-process buffer)))
-            (when p
-              (setf (hi::buffer-process buffer) nil)
-              (process-kill p)))
           (when (eq buffer hi::*current-buffer*)
 	    (setf hi::*current-buffer* nil))
@@ -1069,7 +1065,5 @@
 (objc:defmethod (#/evalSelection: :void) ((self hemlock-text-view) sender)
   (declare (ignore sender))
-  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
-         (doc (#/documentForWindow: dc (#/window self)))
-         (buffer (hemlock-document-buffer doc))
+  (let* ((buffer (hemlock-buffer self))
          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
          (pathname (hi::buffer-pathname buffer))
@@ -1084,7 +1078,5 @@
 (objc:defmethod (#/loadBuffer: :void) ((self hemlock-text-view) sender)
   (declare (ignore sender))
-  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
-         (doc (#/documentForWindow: dc (#/window self)))
-         (buffer (hemlock-document-buffer doc))
+  (let* ((buffer (hemlock-buffer self))
          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
          (pathname (hi::buffer-pathname buffer)))
@@ -1093,7 +1085,5 @@
 (objc:defmethod (#/compileBuffer: :void) ((self hemlock-text-view) sender)
   (declare (ignore sender))
-  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
-         (doc (#/documentForWindow: dc (#/window self)))
-         (buffer (hemlock-document-buffer doc))
+  (let* ((buffer (hemlock-buffer self))
          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
          (pathname (hi::buffer-pathname buffer)))
@@ -1102,7 +1092,5 @@
 (objc:defmethod (#/compileAndLoadBuffer: :void) ((self hemlock-text-view) sender)
   (declare (ignore sender))
-  (let* ((dc (#/sharedDocumentController ns:ns-document-controller))
-         (doc (#/documentForWindow: dc (#/window self)))
-         (buffer (hemlock-document-buffer doc))
+  (let* ((buffer (hemlock-buffer self))
          (package-name (hi::variable-value 'hemlock::current-package :buffer buffer))
          (pathname (hi::buffer-pathname buffer)))
@@ -2261,5 +2249,5 @@
                                   :encoding encoding
                                   :error +null-ptr+))
-         (buffer (hemlock-document-buffer self))
+         (buffer (hemlock-buffer self))
          (old-length (hemlock-buffer-length buffer))
 	 (hi::*current-buffer* buffer)
@@ -2321,5 +2309,5 @@
                  (#/path url)
                  (#/absoluteString url))))
-             (buffer (or (hemlock-document-buffer self)
+             (buffer (or (hemlock-buffer self)
                          (make-buffer-for-document self pathname)))
              (selected-encoding (slot-value (#/sharedDocumentController (find-class 'hemlock-document-controller)) 'last-encoding))
@@ -2401,7 +2389,4 @@
              
 
-(defmethod hemlock-document-buffer (document)
-  (hemlock-buffer document))
-
 (defmethod hemlock-view ((frame hemlock-frame))
   (let ((pane (slot-value frame 'pane)))
@@ -2430,5 +2415,5 @@
   (with-slots (encoding) self
     (setq encoding (nsinteger-to-nsstring-encoding (#/selectedTag popup)))
-    (hi::note-modeline-change (hemlock-document-buffer self))))
+    (hi::note-modeline-change (hemlock-buffer self))))
 
 (objc:defmethod (#/prepareSavePanel: :<BOOL>) ((self hemlock-editor-document)
@@ -2454,5 +2439,5 @@
   (with-slots (encoding textstorage) self
     (let* ((string (#/string textstorage))
-           (buffer (hemlock-document-buffer self)))
+           (buffer (hemlock-buffer self)))
       (case (when buffer (hi::buffer-line-termination buffer))
         (:crlf (unless (typep string 'ns:ns-mutable-string)
@@ -2479,5 +2464,5 @@
                                         url)
   (call-next-method url)
-  (let* ((buffer (hemlock-document-buffer self)))
+  (let* ((buffer (hemlock-buffer self)))
     (when buffer
       (let* ((new-pathname (lisp-string-from-nsstring (#/path url))))
Index: /branches/event-ide/ccl/cocoa-ide/cocoa-listener.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/cocoa-listener.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/cocoa-listener.lisp	(revision 7929)
@@ -49,4 +49,73 @@
   pty)
 
+(defparameter $listener-flush-limit 100)
+
+(defclass cocoa-listener-output-stream (fundamental-character-output-stream)
+  ((lock :initform (make-lock))
+   (hemlock-view :initarg :hemlock-view)
+   (data :initform (make-array (1+ $listener-flush-limit)
+                               :adjustable t :fill-pointer 0
+                               :element-type 'character))))
+
+(defmethod stream-element-type ((stream cocoa-listener-output-stream))
+  (with-slots (data) stream
+    (array-element-type data)))
+
+(defmethod ccl:stream-write-char ((stream cocoa-listener-output-stream) char)
+  (with-slots (data lock) stream
+    (when (with-lock-grabbed (lock)
+	    (>= (vector-push-extend char data) $listener-flush-limit))
+      (stream-force-output stream))))
+
+;; This isn't really thread safe, but it's not too bad...  I'll take a chance - trying
+;; to get it to execute in the gui thread is too deadlock-prone.
+(defmethod hemlock-listener-output-mark-column ((view hi::hemlock-view))
+  (let* ((output-region (hi::variable-value 'hemlock::current-output-font-region
+					    :buffer (hi::hemlock-view-buffer view))))
+    (hi::mark-charpos (hi::region-end output-region))))
+
+;; TODO: doesn't do the right thing for embedded tabs (in buffer or data)
+(defmethod ccl:stream-line-column ((stream cocoa-listener-output-stream))
+  (with-slots (hemlock-view data lock) stream
+    (with-lock-grabbed (lock)
+      (let* ((n (length data))
+             (pos (position #\Newline data :from-end t)))
+        (if (null pos)
+          (+ (hemlock-listener-output-mark-column hemlock-view) n)
+          (- n pos 1))))))
+
+(defmethod ccl:stream-fresh-line  ((stream cocoa-listener-output-stream))
+  (with-slots (hemlock-view data lock) stream
+    (when (with-lock-grabbed (lock)
+            (let ((n (length data)))
+              (unless (if (= n 0)
+                        (= (hemlock-listener-output-mark-column hemlock-view) 0)
+                        (eq (aref data (1- n)) #\Newline))
+                (>= (vector-push-extend #\Newline data) $listener-flush-limit))))
+      (stream-force-output stream))))
+
+(defmethod ccl::stream-finish-output ((stream cocoa-listener-output-stream))
+  (stream-force-output stream))
+
+(defmethod ccl:stream-force-output ((stream cocoa-listener-output-stream))
+  (if (typep *current-process* 'appkit-process)
+    (with-slots (hemlock-view data lock) stream
+      (with-lock-grabbed (lock)
+        (when (> (fill-pointer data) 0)
+          (append-output hemlock-view data)
+          (setf (fill-pointer data) 0))))
+    (with-slots (data) stream
+      (when (> (fill-pointer data) 0)
+        (queue-for-gui #'(lambda () (stream-force-output stream)))))))
+
+(defmethod ccl:stream-clear-output ((stream cocoa-listener-output-stream))
+  (with-slots (data lock) stream
+    (with-lock-grabbed (lock)
+      (setf (fill-pointer data) 0))))
+
+(defmethod ccl:stream-line-length ((stream cocoa-listener-output-stream))
+  ;; TODO: ** compute length from window size **
+  80)
+
 
 (defloadvar *cocoa-listener-count* 0)
@@ -58,9 +127,8 @@
      (backtrace-contexts :initform nil
                          :accessor cocoa-listener-process-backtrace-contexts)
-     (window :reader cocoa-listener-process-window)
-     (buffer :initform nil :reader cocoa-listener-process-buffer)))
+     (window :reader cocoa-listener-process-window)))
   
 
-(defun new-cocoa-listener-process (procname input-fd output-fd peer-fd window buffer)
+(defun new-cocoa-listener-process (procname input-fd peer-fd window)
   (let* ((input-stream (ccl::make-selection-input-stream
                         input-fd
@@ -70,11 +138,4 @@
                                               #$_PC_MAX_INPUT)
                         :encoding :utf-8))
-         (output-stream (ccl::make-fd-stream output-fd :direction :output
-					     :sharing :lock
-					     :elements-per-buffer
-					     (#_fpathconf
-					      output-fd
-					      #$_PC_MAX_INPUT)
-					     :encoding :utf-8))
          (peer-stream (ccl::make-fd-stream peer-fd :direction :output
 					   :sharing :lock
@@ -84,4 +145,7 @@
 					    #$_PC_MAX_INPUT)
 					   :encoding :utf-8))
+         (output-stream (make-instance 'cocoa-listener-output-stream
+                          :hemlock-view (hemlock-view window)))
+
          (proc
           (ccl::make-mcl-listener-process 
@@ -89,19 +153,22 @@
            input-stream
            output-stream
-           #'(lambda ()`
-               (let* ((buf (find *current-process* hi:*buffer-list*
-                                 :key #'hi::buffer-process))
-                      (doc (if buf (hi::buffer-document buf))))
-                 (when doc
-                   (setf (hi::buffer-process buf) nil)
-                   (#/performSelectorOnMainThread:withObject:waitUntilDone:
-                    doc
-                    (@selector #/close)
-                    +null-ptr+
-                    nil))))
+           ;; cleanup function
+           #'(lambda ()
+               (mapcar #'(lambda (buf)
+                           (when (eq (buffer-process buf) *current-process*)
+                             (let ((doc (hi::buffer-document buf)))
+                               (when doc
+                                 (setf (hemlock-document-process doc) nil) ;; so #/close doesn't kill it.
+                                 (#/performSelectorOnMainThread:withObject:waitUntilDone:
+                                  doc
+                                  (@selector #/close)
+                                  +null-ptr+
+                                  nil)))))
+                       hi:*buffer-list*))
            :initial-function
            #'(lambda ()
                (setq ccl::*listener-autorelease-pool* (create-autorelease-pool))
                (ccl::listener-function))
+           :echoing nil
            :class 'cocoa-listener-process)))
     (setf (slot-value proc 'input-stream) input-stream)
@@ -109,7 +176,6 @@
     (setf (slot-value proc 'input-peer-stream) peer-stream)
     (setf (slot-value proc 'window) window)
-    (setf (slot-value proc 'buffer) buffer)
     proc))
-         
+
 
 (defclass hemlock-listener-frame (hemlock-frame)
@@ -180,5 +246,5 @@
           (#_free xlate)
           (setq xlate new translatebuf new bufsize need)))
-      #+debug (#_NSLog #@"got %d bytes of data" :int data-length)
+      #+debug :GZ (#_NSLog #@"got %d bytes of data" :int data-length)
       (with-macptrs ((target (%inc-ptr xlate n)))
         (#/getBytes:range: data target (ns:make-ns-range 0 data-length)))
@@ -217,5 +283,5 @@
             (not (%null-ptr-p (#/fileURL doc))))
       (call-next-method name)
-      (let* ((buffer (hemlock-document-buffer doc))
+      (let* ((buffer (hemlock-buffer doc))
              (bufname (if buffer (hi::buffer-name buffer))))
         (if bufname
@@ -228,7 +294,15 @@
 
 (defclass hemlock-listener-document (hemlock-editor-document)
-    ()
+  ((process :reader %hemlock-document-process :writer (setf hemlock-document-process)))
   (:metaclass ns:+ns-object))
 (declaim (special hemlock-listener-document))
+
+(defgeneric hemlock-document-process (doc)
+  (:method ((unknown t)) nil)
+  (:method ((doc hemlock-listener-document)) (%hemlock-document-process doc)))
+
+;; Nowadays this is nil except for listeners.
+(defun buffer-process (buffer)
+  (hemlock-document-process (hi::buffer-document buffer)))
 
 (defmethod update-buffer-package ((doc hemlock-listener-document) buffer)
@@ -244,11 +318,19 @@
   *listener-background-color*)
 
-
-(defun hemlock::listener-document-send-string (document string)
-  (let* ((buffer (hemlock-document-buffer document))
-         (process (if buffer (hi::buffer-process buffer))))
-    (if process
-      (hi::send-string-to-listener-process process string))))
-
+(defun hemlock-ext:send-string-to-listener (buffer string)
+  (let* ((proc (buffer-process buffer)))
+    (when proc
+      (send-string-to-listener-process proc string))))
+
+;; For use with the :process-info listener modeline field
+(defmethod hemlock-ext:buffer-process-description (buffer)
+  (let ((proc (buffer-process buffer)))
+    (when proc
+      (format nil "~a(~d) [~a]"
+              (ccl:process-name proc)
+              (ccl::process-serial-number proc)
+              ;; TODO: this doesn't really work as a modeline item, because the modeline
+              ;; doesn't get notified when it changes.
+              (ccl:process-whostate proc)))))
 
 (objc:defmethod #/topListener ((self +hemlock-listener-document))
@@ -260,8 +342,5 @@
 
 (defun symbol-value-in-top-listener-process (symbol)
-  (let* ((listenerdoc (#/topListener hemlock-listener-document))
-	 (buffer (unless (%null-ptr-p listenerdoc)
-		   (hemlock-document-buffer listenerdoc)))
-	 (process (if buffer (hi::buffer-process buffer))))
+  (let* ((process (hemlock-document-process (#/topListener hemlock-listener-document))))
      (if process
        (ignore-errors (symbol-value-in-process symbol process))
@@ -269,10 +348,8 @@
   
 (defun hemlock-ext:top-listener-output-stream ()
-  (let* ((doc (#/topListener hemlock-listener-document)))
-    (unless (%null-ptr-p doc)
-      (let* ((buffer (hemlock-document-buffer doc))
-             (process (if buffer (hi::buffer-process buffer))))
-        (when (typep process 'cocoa-listener-process)
-          (cocoa-listener-process-output-stream process))))))
+  (let* ((process (hemlock-document-process (#/topListener hemlock-listener-document))))
+    (when process
+      (setq process (require-type process 'cocoa-listener-process))
+      (cocoa-listener-process-output-stream process))))
 
 
@@ -290,5 +367,5 @@
 			    (format nil
 				    "Listener-~d" *cocoa-listener-count*)))
-	     (buffer (hemlock-document-buffer doc)))
+	     (buffer (hemlock-buffer doc)))
 	(setf (hi::buffer-pathname buffer) nil
 	      (hi::buffer-minor-mode buffer "Listener") t
@@ -308,4 +385,7 @@
     (setq *next-listener-x-pos* nil
           *next-listener-y-pos* nil))
+  (let* ((p (shiftf (hemlock-document-process self) nil)))
+    (when p
+      (process-kill p)))
   (call-next-method))
 
@@ -329,5 +409,5 @@
 		      'hemlock-listener-window-controller
 		      :with-window window))
-	 (listener-name (hi::buffer-name (hemlock-document-buffer self))))
+	 (listener-name (hi::buffer-name (hemlock-buffer self))))
     (with-slots (styles) textstorage
       ;; We probably should be more disciplined about
@@ -354,8 +434,8 @@
         (setf *next-listener-x-pos* (ns:ns-point-x new-point)
               *next-listener-y-pos* (ns:ns-point-y new-point))))
-    (setf (hi::buffer-process (hemlock-document-buffer self))
+    (setf (hemlock-document-process self)
 	  (let* ((tty (slot-value controller 'clientfd))
 		 (peer-tty (#/fileDescriptor (slot-value controller 'filehandle))))
-	    (new-cocoa-listener-process listener-name tty tty peer-tty window (hemlock-document-buffer self))))
+	    (new-cocoa-listener-process listener-name tty peer-tty window)))
     controller))
 
@@ -368,5 +448,5 @@
   (let* ((range-start (ns:ns-range-location range))
          (range-end (+ range-start (ns:ns-range-length range)))
-         (buffer (hemlock-document-buffer self))
+         (buffer (hemlock-buffer self))
          (protected-region (hi::buffer-protected-region buffer)))
     (if protected-region
@@ -383,7 +463,6 @@
 (objc:defmethod (#/interrupt: :void) ((self hemlock-listener-document) sender)
   (declare (ignore sender))
-  (let* ((buffer (hemlock-document-buffer self))
-         (process (if buffer (hi::buffer-process buffer))))
-    (when (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process self)))
+    (when process
       (ccl::force-break-in-listener process))))
 
@@ -392,8 +471,7 @@
 (objc:defmethod (#/exitBreak: :void) ((self hemlock-listener-document) sender)
   (declare (ignore sender))
-  (let* ((buffer (hemlock-document-buffer self))
-         (process (if buffer (hi::buffer-process buffer))))
-    (log-debug  "~&exitBreak buffer ~s process ~s" buffer process)
-    (when (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process self)))
+    (log-debug  "~&exitBreak process ~s" process)
+    (when process
       (process-interrupt process #'abort-break))))
 
@@ -402,7 +480,6 @@
 
 (objc:defmethod (#/backtrace: :void) ((self hemlock-listener-document) sender)
-  (let* ((buffer (hemlock-document-buffer self))
-         (process (if buffer (hi::buffer-process buffer))))
-    (when (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process self)))
+    (when process
       (let* ((context (listener-backtrace-context process)))
         (when context
@@ -435,7 +512,6 @@
                             
 (objc:defmethod (#/restarts: :void) ((self hemlock-listener-document) sender)
-  (let* ((buffer (hemlock-document-buffer self))
-         (process (if buffer (hi::buffer-process buffer))))
-    (when (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process self)))
+    (when process
       (let* ((context (listener-backtrace-context process)))
         (when context
@@ -444,7 +520,6 @@
 (objc:defmethod (#/continue: :void) ((self hemlock-listener-document) sender)
   (declare (ignore sender))
-  (let* ((buffer (hemlock-document-buffer self))
-         (process (if buffer (hi::buffer-process buffer))))
-    (when (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process self)))
+    (when process
       (let* ((context (listener-backtrace-context process)))
         (when context
@@ -464,27 +539,7 @@
   ;; So far, all actions demand that there be an underlying process, so
   ;; check for that first.
-  (let* ((buffer (hemlock-document-buffer doc))
-         (process (if buffer (hi::buffer-process buffer))))
-    (if (typep process 'cocoa-listener-process)
+  (let* ((process (hemlock-document-process doc)))
+    (if process
       (let* ((action (#/action item)))
-	#+GZ (log-debug "Validate menu item buffer: ~s process: ~s action: ~s context ~s" buffer process
-			(cond ((eql action (@selector #/revertDocumentToSaved:))
-			       "revertDocumentToSaved:")
-			      ((eql action (@selector #/saveDocument:))
-			       "saveDocument:")
-			      ((eql action (@selector #/saveDocumentAs:))
-			       "saveDocumentAs:")
-			      ((eql action (@selector #/interrupt:))
-			       "interrupt")
-			      ((eql action (@selector #/continue:))
-			       "continue")
-			      ((eql action (@selector #/backtrace:))
-			       "backtrace")
-			      ((eql action (@selector #/exitBreak:))
-			       "exitBreak:")
-			      ((eql action (@selector #/restarts:))
-			       "restarts:")
-			      (t action))
-			(cocoa-listener-process-backtrace-contexts process))
         (cond
           ((or (eql action (@selector #/revertDocumentToSaved:))
@@ -524,18 +579,16 @@
 
 (defmethod ui-object-note-package ((app ns:ns-application) package)
-  (with-autorelease-pool
-      (process-interrupt *cocoa-event-process*
-			 #'(lambda (proc name)
-			     (dolist (buf hi::*buffer-list*)
-			       (when (eq proc (hi::buffer-process buf))
-				 (setf (hi::variable-value 'hemlock::current-package :buffer buf) name))))
-			 *current-process*
-			 (shortest-package-name package))))
+  (let ((proc *current-process*)
+        (name (shortest-package-name package)))
+    (execute-in-gui #'(lambda ()
+                        (dolist (buf hi::*buffer-list*)
+                          (when (eq proc (buffer-process buf))
+                            (setf (hi::variable-value 'hemlock::current-package :buffer buf) name)))))))
 
 ;;; This is basically used to provide INPUT to the listener process, by
 ;;; writing to an fd which is conntected to that process's standard
 ;;; input.
-(defmethod hi::send-string-to-listener-process ((process cocoa-listener-process)
-                                                string &key path package)
+(defmethod send-string-to-listener-process ((process cocoa-listener-process)
+                                            string &key path package)
   (let* ((stream (cocoa-listener-process-input-peer-stream process)))
     (labels ((out-raw-char (ch)
@@ -570,12 +623,9 @@
   (declare (ignore selection))
   (#/performSelectorOnMainThread:withObject:waitUntilDone:
-   (#/delegate *NSApp*) (@selector #/ensureListener:) +null-ptr+ #$YES)
-  (let* ((top-listener-document (#/topListener hemlock-listener-document)))
-    (if top-listener-document
-      (let* ((buffer (hemlock-document-buffer top-listener-document)))
-	(if buffer
-	  (let* ((proc (hi::buffer-process buffer)))
-	    (if (typep proc 'cocoa-listener-process)
-	      proc)))))))
+   (#/delegate *NSApp*)
+   (@selector #/ensureListener:)
+   +null-ptr+
+   #$YES)
+  (hemlock-document-process (#/topListener hemlock-listener-document)))
 
 (defmethod ui-object-eval-selection ((app ns:ns-application)
@@ -583,33 +633,33 @@
   (let* ((target-listener (ui-object-choose-listener-for-selection
 			   app selection)))
-    (if (typep target-listener 'cocoa-listener-process)
-        (destructuring-bind (package path string) selection
-        (hi::send-string-to-listener-process target-listener string :package package :path path)))))
+    (when target-listener
+      (destructuring-bind (package path string) selection
+        (send-string-to-listener-process target-listener string :package package :path path)))))
 
 (defmethod ui-object-load-buffer ((app ns:ns-application) selection)
   (let* ((target-listener (ui-object-choose-listener-for-selection app nil)))
-    (if (typep target-listener 'cocoa-listener-process)
-        (destructuring-bind (package path) selection
-          (let ((string (format nil "(load ~S)" path)))
-            (hi::send-string-to-listener-process target-listener string :package package :path path))))))
+    (when target-listener
+      (destructuring-bind (package path) selection
+        (let ((string (format nil "(load ~S)" path)))
+          (send-string-to-listener-process target-listener string :package package :path path))))))
 
 (defmethod ui-object-compile-buffer ((app ns:ns-application) selection)
   (let* ((target-listener (ui-object-choose-listener-for-selection app nil)))
-    (if (typep target-listener 'cocoa-listener-process)
-        (destructuring-bind (package path) selection
-          (let ((string (format nil "(compile-file ~S)" path)))
-            (hi::send-string-to-listener-process target-listener string :package package :path path))))))
+    (when target-listener
+      (destructuring-bind (package path) selection
+        (let ((string (format nil "(compile-file ~S)" path)))
+          (send-string-to-listener-process target-listener string :package package :path path))))))
 
 (defmethod ui-object-compile-and-load-buffer ((app ns:ns-application) selection)
   (let* ((target-listener (ui-object-choose-listener-for-selection app nil)))
-    (if (typep target-listener 'cocoa-listener-process)
-        (destructuring-bind (package path) selection
-          (let ((string (format nil "(progn (compile-file ~S)(load ~S))" 
-                                path
-                                (make-pathname :directory (pathname-directory path)
-                                               :name (pathname-name path)
-                                               :type (pathname-type path)))))
-            (hi::send-string-to-listener-process target-listener string :package package :path path))))))
+    (when target-listener
+      (destructuring-bind (package path) selection
+        (let ((string (format nil "(progn (compile-file ~S)(load ~S))" 
+                              path
+                              (make-pathname :directory (pathname-directory path)
+                                             :name (pathname-name path)
+                                             :type (pathname-type path)))))
+          (send-string-to-listener-process target-listener string :package package :path path))))))
 
        
-  
+ 
Index: /branches/event-ide/ccl/cocoa-ide/cocoa-window.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/cocoa-window.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/cocoa-window.lisp	(revision 7929)
@@ -157,11 +157,5 @@
   (flet ((cocoa-startup ()
 	   ;; Start up a thread to run periodic tasks.
-	   (process-run-function "housekeeping"
-				 #'(lambda ()
-				     (loop
-                                       (ccl::%nanosleep ccl::*periodic-task-seconds*
-							ccl::*periodic-task-nanoseconds*)
-                                       (ccl::housekeeping))))
-	   
+	   (process-run-function "housekeeping" #'ccl::housekeeping-loop)
            (with-autorelease-pool
              (enable-foreground)
Index: /branches/event-ide/ccl/cocoa-ide/hemlock/src/lispmode.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/hemlock/src/lispmode.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/hemlock/src/lispmode.lisp	(revision 7929)
@@ -331,5 +331,7 @@
     (unless (lisp-info-ending-quoted line-info)
       (loop 
-	(find-lisp-char mark)
+	(unless (find-lisp-char mark)
+          (error "Expected at least a newline!"))
+
 	(ecase (character-attribute :lisp-syntax (next-character mark))
 	  
Index: /branches/event-ide/ccl/cocoa-ide/hemlock/src/listener.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/hemlock/src/listener.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/hemlock/src/listener.lisp	(revision 7929)
@@ -198,6 +198,5 @@
           (move-mark (value buffer-input-mark) (current-point))
           (append-font-regions (current-buffer))
-          (hi::send-string-to-listener-process (hi::buffer-process (current-buffer))
-                                           string))))))
+          (hemlock-ext:send-string-to-listener (current-buffer) string))))))
 
 (defparameter *pop-string* ":POP
@@ -212,11 +211,6 @@
       (if (and (null (next-character point))
 	       (null (next-character input-mark)))
-	  (listener-document-send-string (hi::buffer-document (current-buffer)) *pop-string*)
-	  (delete-next-character-command p)))))
-
-             
-
-
-
+        (hemlock-ext:send-string-to-listener (current-buffer) *pop-string*)
+        (delete-next-character-command p)))))
 
 
@@ -518,6 +512,7 @@
 	 (expr (with-input-from-region (s region)
 		 (read s))))
-    (let* ((*print-pretty* t))
-      (format t "~&~s~&" (funcall expander expr)))))
+    (let* ((*print-pretty* t)
+	   (expansion (funcall expander expr)))
+      (format t "~&~s~&" expansion))))
 
 (defcommand "Editor Macroexpand-1 Expression" (p)
@@ -548,16 +543,12 @@
 (defcommand "Editor Evaluate Buffer" (p)
   "Evaluates the text in the current buffer in the editor Lisp."
-  "Evaluates the text in the current buffer redirecting *Standard-Output* to
-   the echo area.  This occurs in the editor Lisp.  The prefix argument is
-   ignored."
   (declare (ignore p))
   (message "Evaluating buffer in the editor ...")
   (with-input-from-region (stream (buffer-region (current-buffer)))
-    (let ((*standard-output* *echo-area-stream*))
-      (in-lisp
-       (do ((object (read stream nil lispbuf-eof) 
-		    (read stream nil lispbuf-eof)))
-	   ((eq object lispbuf-eof))
-	 (eval object))))
+    (in-lisp
+     (do ((object (read stream nil lispbuf-eof) 
+                  (read stream nil lispbuf-eof)))
+         ((eq object lispbuf-eof))
+       (eval object)))
     (message "Evaluation complete.")))
 
Index: /branches/event-ide/ccl/cocoa-ide/hemlock/src/modeline.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/hemlock/src/modeline.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/hemlock/src/modeline.lisp	(revision 7929)
@@ -204,10 +204,5 @@
  :function #'(lambda (buffer window)
                (declare (ignore window))
-               (let* ((proc (buffer-process buffer)))
-                 (when proc
-                   (format nil "~a(~d) [~a]"
-                           (ccl::process-name proc)
-                           (ccl::process-serial-number proc)
-                           (ccl::process-whostate proc))))))
+               (hemlock-ext:buffer-process-description buffer)))
 
 (defparameter *default-modeline-fields*
Index: /branches/event-ide/ccl/cocoa-ide/hemlock/src/package.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/hemlock/src/package.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/hemlock/src/package.lisp	(revision 7929)
@@ -368,4 +368,6 @@
    #:edit-single-definition
    #:change-active-pane
+   #:send-string-to-listener
+   #:buffer-process-description
    ))
 
Index: /branches/event-ide/ccl/cocoa-ide/hemlock/src/views.lisp
===================================================================
--- /branches/event-ide/ccl/cocoa-ide/hemlock/src/views.lisp	(revision 7928)
+++ /branches/event-ide/ccl/cocoa-ide/hemlock/src/views.lisp	(revision 7929)
@@ -178,4 +178,5 @@
 
 (defmethod execute-hemlock-key ((view hemlock-view) key)
+  #+gz (log-debug "~&execute-hemlock-key ~s" key)
   (if (or (symbolp key) (functionp key))
     (funcall key)
@@ -183,4 +184,5 @@
       (multiple-value-bind (main-binding transparent-bindings)
 			   (get-command-binding-for-key view key)
+	#+gz (log-debug "~&  binding ~s ~s" main-binding transparent-bindings)
 	(when main-binding
 	  (let* ((*last-last-command-type* (shiftf (hemlock-last-command-type view) nil))
