 (defun merlin-wait-for-answer ()
   "Waits for merlin to answer."
   (while (not merlin-ready)
-    (accept-process-output merlin-process 0.1 nil t))
+    (accept-process-output (merlin-process) 0.1 nil t))
   merlin-result)
 
 (defun merlin-send-command-async (command callback-if-success &optional callback-if-exn)

(defun merlin-goto-point (data)
  "Go to the point indicated by `DATA' which must be an assoc list with fields
line and col"
  (goto-char (point-max))
  (let* ((line-max (line-number-at-pos nil))
         (col-max  (current-column))
         (line     (cdr (assoc 'line data)))
         (col      (cdr (assoc 'col data))))
    (when (<= line line-max)
      (goto-char (point-min))
      (forward-line (1- line))
      (move-to-column (max 0 col)))))

(defun merlin-goto-file-and-point (data)
  "Go to the file and position indicated by DATA which is an assoc list

  "Return the completion for ident IDENT."
  (merlin-send-command (list '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)))

(defun merlin-get-position ()
  "Get the current position of merlin."
  (car (merlin-parse-position (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)))))

(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)))))

(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))))

;;;;;;;;;;;;;;;;;;;;
;; FILE SWITCHING ;;
