 
 (defun tern-mode-enable ()
   (set (make-local-variable 'tern-known-port) nil)
+  (set (make-local-variable 'tern-server) "127.0.0.1")
+  (set (make-local-variable 'tern-explicit-port) nil)
   (set (make-local-variable 'tern-project-dir) nil)
   (set (make-local-variable 'tern-last-point-pos) nil)
   (set (make-local-variable 'tern-last-completions) nil)

                    (with-current-buffer (find-file-noselect (expand-file-name (cdr (assq 'name file)) tern-project-dir))
                      (setf tern-buffer-is-dirty nil))))
                (funcall f data))
               ((not (eq mode :silent)) (tern-message "Request failed: %s" (cdr err))))))
     doc)))

(defun tern-send-buffer-to-server ()

      (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)
        (return (funcall c nil "Buffer is not associated with a file")))
      (let ((deactivate-mark nil)
            (port-file (expand-file-name ".tern-port" (tern-project-dir))))
        (when (file-exists-p port-file)
          (let ((port (string-to-number (with-temp-buffer
                                          (insert-file-contents port-file)
                                          (buffer-string)))))
            (unless (eq port ignore-port)
              (setf tern-known-port port)
              (return (funcall c port nil))))))
      (tern-start-server c))))

(defvar tern-command
  (let* ((script-file (or load-file-name
