     (merlin-wait-for-answer)))
 
 ;; SPECIAL CASE OF COMMANDS
-(defun merlin-rewind (&optional dont-load-project)
+(defun merlin-rewind ()
   "Rewind the knowledge of merlin of the current buffer to zero."
   (interactive)
-  (unless dont-load-project
-    (when merlin-project-file
-      (merlin-send-command (list 'project 'load merlin-project-file))))
-  (let ((kind (if (string-equal ".mli" (file-name-extension buffer-file-name))
-                  'mli 'ml)))
-    (merlin-send-command (list 'reset kind buffer-file-name)))
+  (merlin-send-command (list 'reset 'name buffer-file-name))
   (merlin-error-reset)
   (setq merlin-lock-point (point-min)))
 
 (defun merlin-refresh ()
   "Refresh changed merlin cmis."
   (interactive)
-  (merlin-send-command 'refresh)
+  (merlin-send-command '(refresh quick))
   (merlin-after-save))
+
+(defun merlin-refresh-full ()
+  "Refresh all merlin cmis."
+  (interactive)
+  (merlin-send-command 'refresh))
 
 (defun merlin-get-completion (ident)
   "Return the completion for ident IDENT."
-  (merlin-send-command (list 'complete 'prefix ident 'at
-                             (merlin-unmake-point (point)))))
+  (merlin-send-command (list 'complete 'prefix ident 'at (merlin-unmake-point (point)))))
 
 (defun merlin-get-position ()
   "Get the current position of merlin."
-  (merlin-parse-position
-   (merlin-send-command
-    '(seek position))))
+  (merlin-make-point (merlin-send-command '(seek position))))
 
 (defun merlin-seek-before (point)
   "Move merlin's point to the valid definition before POINT."
-  (merlin-parse-position
-   (merlin-send-command
-    (list 'seek 'before (merlin-unmake-point point)))))
+  (merlin-make-point (merlin-send-command (list 'seek 'before (merlin-unmake-point point)))))
 
 (defun merlin-seek-exact (point)
   "Move merlin's point to the definition containing POINT."
-  (merlin-parse-position
-   (merlin-send-command
-    (list 'seek 'exact (merlin-unmake-point point)))))
+  (merlin-make-point (merlin-send-command (list 'seek 'exact (merlin-unmake-point point)))))
+
+(defun merlin-seek-end ()
+  "Move merlin's point to the end of its own view of the buffer."
+  (merlin-make-point (merlin-send-command '(seek end))))
 
 ;;;;;;;;;;;;;;;;;;;;
 ;; FILE SWITCHING ;;

                   (substitute-command-keys "\\[merlin-pop-stack]")))
      (save-excursion (save-selected-window (funcall do-open))))))

(defun merlin-parse-position (data)
  "Position commands return a pair of a physical position (line, col) and a
logical position (a path in the document)."
  (cons
    (merlin-make-point (cdr (assoc 'pos data)))
    (cdr (assoc 'path data))))

(defun merlin-path-common-prefix (p1 p2)
  (cond ((equal p1 p2)
         p1)
        ((and (listp p1) (listp p2))
         (let* ((head (list nil))
                (tail head))
           (while (and p1 p2 (equal (car p1) (car p2)))
             (setcdr tail (list (car p1)))
             (setq tail (cdr tail))
             (setq p1 (cdr p1))
             (setq p2 (cdr p2)))
           (when (and p1 p2)
             (let ((cell (merlin-path-common-prefix (car p1) (car p2))))
               (when cell (setcdr tail (list cell)))))
           (cdr head)))
        (nil)))

(defun merlin-path-is-recursive (path)
  (let ((isrec nil))
    (while (and (not isrec) path (listp path))
      (setq isrec (merlin-path-is-recursive (car path)))
      (setq path (cdr path)))
    (or isrec (and (stringp path)
                   (or (string-equal path "rec")
                       (string-equal path "class")
                       (string-equal path "object"))))))

(defun merlin-make-point (data)
  "Transform DATA (a remote merlin position) into a point."
  (save-excursion

  "Hold a table mapping completion cache for auto-complete.")
(make-variable-buffer-local 'merlin-ac-cache)

(defvar merlin-completion-at-point-cache-query (cons "" 0)
  "The cache for calls to completion-at-point so that it does not
trigger useless merlin calls.")
(make-variable-buffer-local 'merlin-completion-at-point-cache-query)


;; Type related variables
(defvar merlin-enclosing-types nil
  "List containing the enclosing type.")
