       (when (and (not (eq buf (current-buffer)))
                  (buffer-local-value 'tern-mode buf)
                  (buffer-local-value 'tern-buffer-is-dirty buf)
-                 (equal tern-project-dir (buffer-local-value 'tern-project-dir buf)))
+                 (equal (tern-project-dir) (with-current-buffer buf (tern-project-dir))))
         (with-current-buffer buf
           (push `((type . "full")
                   (name . ,(tern-project-relative-file))

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

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

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