     (merlin-wait-for-answer)))
 
 ;; SPECIAL CASE OF COMMANDS
+
 (defun merlin-rewind ()
   "Rewind the knowledge of merlin of the current buffer to zero."
   (interactive)
   (let ((ext (file-name-extension buffer-file-name)))
-    (merlin-send-command (list 'reset (if (string-equal ext "mli") 'mli 'ml) buffer-file-name))
+    (merlin-send-command
+      `(reset ,(if (string-equal ext "mli") 'mli 'ml) ,buffer-file-name))
     (merlin-error-reset)
-    (setq merlin-lock-point (point-min))))
+    (setq merlin-dirty-point (point-min))))
 
 (defun merlin-refresh ()
   "Refresh changed merlin cmis."
   (interactive)
-  (merlin-send-command '(refresh quick))
+  (merlin-send-command 'refresh)
   (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
+    `(complete prefix ,ident at ,(merlin-unmake-point (point)))))
 
 (defun merlin-parse-position (result)
-  (list
-   (merlin-make-point (lookup-default 'cursor result nil))
-   (lookup-default 'marker result nil)))
+  "Returns a pair whose first member is a point set at merlin cursor position
+  and second member is the state of the marker"
+  (cons (merlin-make-point (lookup-default 'cursor result nil))
+        (when (equal (lookup-default 'marker result nil) 'true) t)))
+
+(defun merlin-send-cursor-command (command &optional callback-if-exn)
+  "Send COMMAND (with arguments ARGS) to merlin and returns the result parsed
+  as a position."
+  (merlin-parse-position (merlin-send-command command callback-if-exn)))
+
 
 (defun merlin-get-position ()
   "Get the current position of merlin."
-  (car (merlin-parse-position (merlin-send-command '(seek position)))))
+  (car (merlin-send-cursor-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-send-cursor-command
+    `(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-send-cursor-command
+    `(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-parse-position (merlin-send-command '(seek end))))
+  (merlin-send-cursor-command '(seek end)))
 
 ;;;;;;;;;;;;;;;;;;;;
 ;; FILE SWITCHING ;;

  nil :lighter (:eval (merlin-lighter))
  :keymap merlin-mode-map
  (if merlin-mode
      (if (merlin-can-handle-buffer)
          (merlin-setup)
        (progn
          (when (buffer-file-name) (message "merlin can only operate on ml files"))
          (merlin-mode -1)))
    (when (merlin-can-handle-buffer)
      (merlin-error-gc)
      (when merlin-lock-zone-highlight-overlay

(defun merlin-sync-edit (start end length)
  "Retract the locked zone after an edit.
Called when an edit is made by the user."
  (if (and merlin-mode (< start merlin-dirty-point))
      (progn (setq merlin-dirty-point (1- start))
             (merlin-sync-lock-zone-display))))

(defun merlin-sync-to-point (&optional point)
  "Makes sure the buffer is synchronized on merlin-side and centered around (point)."
  (unless point (setq point (point)))
  (merlin-tell-to-point point)
  (merlin-sync-lock-zone-display))

;;;;;;;;;;;;;;;;;;
