   "Return the lighter for merlin which indicates the status of merlin process."
   (if (merlin-process-dead-p) " merlin (DEAD)"
     (progn
-      (let* ((messages nil)
-             (project (merlin--project-get-cached)))
+      (let ((messages nil))
         (when merlin-report-errors-in-lighter
-          (cond ((cdr project) (add-to-list 'messages "errors in .merlin"))
-                ((not (car project)) (add-to-list 'messages "no .merlin"))))
+          (cond ((not merlin--project-cache) nil)
+                ((cdr merlin--project-cache) (add-to-list 'messages "errors in .merlin"))
+                ((not (car merlin--project-cache)) (add-to-list 'messages "no .merlin"))))
         (when merlin-erroneous-buffer
           (add-to-list 'messages "errors in buffer"))
         (when merlin-show-instance-in-lighter


;; Misc
(defvar merlin--project-cache nil "Cache for merlin--project-get")
(make-variable-buffer-local 'merlin--project-cache)
(defvar merlin--project-failures nil
  "When loading .merlin, list of errors reported. Only update error messages if
  error list changes")
(make-variable-buffer-local 'merlin--project-failures)

;;;;;;;;;;;

  "Returns a pair of two string lists (dot_merlins . failures) with a list of
.merlins file loaded and a list of error messages, if any error occured during
loading"
  (let* ((r (merlin-send-command '(project get)))
         (failed (cdr (assoc 'failures r)))
         (result (cdr (assoc 'result r)))
         (ret (cons result failed)))
    (setq merlin--project-cache ret)
    ret))

(defun merlin-goto-project-file ()
  "Goto the merlin file corresponding to the current file."
