Index: /trunk/source/cocoa-ide/ide-contents/Resources/English.lproj/preferences.nib/info.nib
===================================================================
--- /trunk/source/cocoa-ide/ide-contents/Resources/English.lproj/preferences.nib/info.nib	(revision 12103)
+++ /trunk/source/cocoa-ide/ide-contents/Resources/English.lproj/preferences.nib/info.nib	(revision 12104)
@@ -8,5 +8,7 @@
 	<integer>4</integer>
 	<key>IBOpenObjects</key>
-	<array/>
+	<array>
+		<integer>1500949</integer>
+	</array>
 	<key>IBSystem Version</key>
 	<string>9G55</string>
Index: /trunk/source/cocoa-ide/start.lisp
===================================================================
--- /trunk/source/cocoa-ide/start.lisp	(revision 12103)
+++ /trunk/source/cocoa-ide/start.lisp	(revision 12104)
@@ -88,17 +88,75 @@
     (require :swank))
 
-(defun gui-swank-port ()
-  ;; TODO: get the port from a user preference and use
-  ;;       the global as a fallback
-  *default-gui-swank-port*)
-
 (defun try-starting-swank ()
   (unless *ccl-swank-active-p*
-   (handler-case (swank:create-server :port (gui-swank-port) :dont-close t)
-     (serious-condition (c)
-       (setf *ccl-swank-active-p* nil)
-       (format t "~%Error starting swank server: ~A~%" c)
-       (force-output))
-     (:no-error (result) (setf *ccl-swank-active-p* t)))))
+    ;; try to determine the user preferences concerning the swank port number
+    ;; and whether the swank server should be started. If the user says start
+    ;; it, and we can determine a valid port for it, start it up
+    (let* ((defaults (handler-case (#/values (#/sharedUserDefaultsController ns:ns-user-defaults-controller))
+                       (serious-condition (c) 
+                         (progn (format t "~%ERROR: Unable to get preferences from the Shared User Defaults Controller")
+                                nil))))
+           (start-swank-pref (and defaults (#/valueForKey: defaults #@"startSwankServer")))
+           (start-swank? (cond
+                           ;; the user default is not initialized
+                           ((or (null start-swank-pref)
+                                (%null-ptr-p start-swank-pref)) nil)
+                           ;; examine the user default
+                           ((typep start-swank-pref 'ns:ns-number) 
+                            (case (#/intValue start-swank-pref)
+                              ;; don't start swank
+                              (0 nil)
+                              ;; start swank
+                              (1 t)
+                              ;; the user default value is incomprehensible
+                              (otherwise (progn
+                                           (format t "~%ERROR: Unrecognized value in user preference 'startSwankServer': ~S"
+                                                   start-swank-pref)
+                                           nil))))
+                           ;; the user default value is incomprehensible
+                           (t (progn
+                                (format t "~%ERROR: Unrecognized value type in user preference 'startSwankServer': ~S"
+                                        start-swank-pref)
+                                nil))))
+           (swank-port-pref (and defaults (#/valueForKey: defaults #@"swankPort")))
+           (swank-port (cond
+                         ;; the user default is not initialized
+                         ((or (null swank-port-pref)
+                              (%null-ptr-p swank-port-pref)) nil)
+                         ;; examine the user default
+                         ((typep swank-port-pref 'ns:ns-string) 
+                          (handler-case (let* ((port-str (lisp-string-from-nsstring swank-port-pref))
+                                               (port (parse-integer port-str :junk-allowed nil)))
+                                          (or port *default-gui-swank-port*))
+                            ;; parsing the port number failed
+                            (ccl::parse-integer-not-integer-string (c)
+                              (setf *ccl-swank-active-p* nil)
+                              (format t "~%Error starting swank server; the swank-port user preference is not a valid port number: ~S~%"
+                                      port-str)
+                              nil)))
+                         ;; the user default value is incomprehensible
+                         (t (progn
+                              (format t "~%ERROR: Unrecognized value type in user preference 'swankPort': ~S"
+                                      swank-port-pref)
+                              nil)))))
+      (if (and start-swank? swank-port)
+          ;; try to start the swank server
+          (handler-case (progn
+                          (swank:create-server :port swank-port :dont-close t)
+                          (setf *ccl-swank-active-p* t)
+                          (setf *active-gui-swank-port* swank-port)
+                          swank-port)
+            ;; swank server creation failed
+            (serious-condition (c)
+              (setf *ccl-swank-active-p* nil)
+              (setf *active-gui-swank-port* nil)
+              (format t "~%Error starting swank server: ~A~%" c)
+              nil))
+          ;; don't try to start the swank server
+          (progn
+            (setf *ccl-swank-active-p* nil)
+            (setf *active-gui-swank-port* nil)
+            nil)))
+    (force-output)))
 
 (defmethod toplevel-function ((a cocoa-application) init-file)
Index: /trunk/source/cocoa-ide/swank.lisp
===================================================================
--- /trunk/source/cocoa-ide/swank.lisp	(revision 12103)
+++ /trunk/source/cocoa-ide/swank.lisp	(revision 12104)
@@ -2,4 +2,5 @@
 
 (defparameter *default-gui-swank-port* 4564)
+(defparameter *active-gui-swank-port* nil)
 (defparameter *ccl-swank-active-p* nil)
 
