                                                               (delete-process proc)
                                                               (setf tern-known-port nil)))
                                  (set-process-filter proc nil)
-                                 (funcall c tern-known-port nil))))))
+                                 (funcall c (tern-known-port) nil))))))
 
 (defvar tern-command-generation 0)
 (defvar tern-activity-since-command -1)

  (setf tern-last-file-name (buffer-file-name))
  tern-project-dir)

(defun tern-find-server (c &optional ignore-port)
  (cl-block nil
    (when tern-known-port
      (cl-return (if (consp tern-known-port)
                     (funcall c nil (cdr tern-known-port))
                   (funcall c tern-known-port nil))))
    (if tern-explicit-port
        (funcall c tern-explicit-port nil)
      (unless (buffer-file-name)

(defvar tern-explicit-port nil)
(defvar tern-project-dir nil)
(defvar tern-last-file-name nil)
(defvar tern-last-project-dir nil)

(defun tern-message (fmt &rest objects)
  (apply 'message fmt objects))
