                               #'(lambda (err) (message "No such file (message: %s)" err)))))
     (when file (find-file-other-window file))))
 (defun merlin-switch-to-ml (name)
-  "Switch to a ML file."
+  "Switch to the ML file corresponding to the module NAME."
   (interactive (list (completing-read "Module:" (merlin-list-by-ext "ml"))))
   (merlin-switch-to name "ml"))
 
 (defun merlin-switch-to-mli (name)
-  "Switch to a MLI file."
+  "Switch to the MLI file corresponding to the module NAME."
   (interactive (list (completing-read "Module:" (merlin-list-by-ext "mli"))))
   (merlin-switch-to name "mli"))
                
 ;; Get the type of an element
-
-(defun merlin-trim (s)
-  (replace-regexp-in-string "\n\\'" "" s))
-
 (defun merlin-type-of-expression-local (exp callback-if-success &optional callback-if-exn)
-  "Get the type of an expression inside the local context."
+  "Get the type of EXP inside the local context."
   (if exp
       (merlin-send-command-async "type"
                                  (list "expression" exp "at"

;; UTILS

(defun merlin-debug (s)
  "If in debug-mode (controlled by `merlin-debug', output the given string
   on the buffer associated to the current merlin process."
  (with-current-buffer (merlin-get-process-buffer-name)
    (insert s)))

(defun merlin-compute-prefix (ident)
  "Compute the prefix of an identifier. The prefix of Foo.bar is Foo. and the prefix of bar is \"\"."
  (let* ((l (butlast (split-string ident "\\.")))
         (s (mapconcat 'identity l ".")))
    (if (string-equal s "") s (concat s "."))))

(defun merlin-goto-point (data)
  "Goes to the point indicated by `DATA' which must be an assoc list with fields line and col"
  (goto-char (point-min))
  (forward-line (1- (cdr (assoc 'line data))))
  (forward-char (cdr (assoc 'col data)))
)
(defun merlin-goto-file-and-point (data)
  "Goes to the file and position indicated by `DATA' which is an assoc list containing fields file, line and col"
  (if (> (length (cdr (assoc 'file data))) 0)
      (find-file-other-window (cdr (assoc 'file data))))
  (merlin-goto-point (cdr (assoc 'pos data))))

(defun merlin-make-point (data)
  "Create a point from a couple line / col."
  (save-excursion
    (beginning-of-line)
    ;; goto-line
    (merlin-goto-point data)
    (point)))
(defun merlin-make-bounds (data)
  "From a json object {\"start\": LOC1; \"end\": LOC2}
return (LOC1 . LOC2)."
  (cons
   (merlin-make-point (cdr (assoc 'start data)))
   (merlin-make-point (cdr (assoc 'end data)))))

(defun merlin-unmake-point (point)
  "Destruct the given point to line / col."
  (save-excursion
    (goto-char point)
    (list

  "The flags to give to ocamlmerlin."
  :group 'merlin :type '(repeat string))
(defcustom merlin-automatically-garbage-processes t
  "If non-nil, deletes a process when it has no more users.  If nil, keep it."
  :group 'merlin :type 'boolean)
(defcustom merlin-rewind-after-refresh t
  "If non-nil, rewind the buffer after refresh."
  :group 'merlin :type 'boolean)
(defcustom merlin-use-auto-complete-mode nil
  "If non nil, use `auto-complete-mode' in any buffer."
  :group 'merlin :type 'boolean)

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