 (defvar tern-last-argument-hints nil)
 (defvar tern-buffer-is-dirty nil)
 
-(defun tern-local-filepath ()
-  (substring (buffer-file-name) (length tern-project-dir)))
+(defun tern-project-relative-file ()
+  (substring (buffer-file-name) (length (tern-project-dir))))
 
 ;; FIXME send partial files when in a big file
 

(defun tern-find-definition ()
  (interactive)
  (tern-run-request (lambda (data)
                      (push (cons (tern-local-filepath) (point)) tern-find-definition-stack)
                      (let ((too-long (nthcdr 20 tern-find-definition-stack)))
                        (when too-long (setf (cdr too-long) nil)))
                      (tern-go-to-position (cdr (assoc 'file data))
                                           (1+ (cdr (assoc 'start data)))))
                    `((type . "definition")
                      (file . ,(tern-local-filepath))
                      (end . ,(1- (point))))))

(defun tern-pop-find-definition ()

      (lambda ()
        (tern-run-request #'tern-do-complete
                          `((type . "completions")
                            (file . ,(tern-project-relative-file))
                            (end . ,(1- (point))))))))

(defun tern-do-complete (data)
