   (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-file-name) nil)
   (set (make-local-variable 'tern-last-point-pos) nil)
   (set (make-local-variable 'tern-last-completions) nil)
   (set (make-local-variable 'tern-last-argument-hints) nil)

        (funcall c nil json)))))

(defun tern-project-dir ()
  (or (and (not (buffer-file-name)) "")
      (let ((project-dir (file-name-directory (buffer-file-name))))
        (cl-loop for cur = project-dir then (let ((shorter (file-name-directory (directory-file-name cur))))
                                              (and (< (length shorter) (length cur)) shorter))
                 while cur do
                 (when (file-exists-p (expand-file-name ".tern-project" cur))
                   (cl-return (setf project-dir cur))))
        project-dir)))

(defun tern-find-server (c &optional ignore-port)
  (cl-block nil

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

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