         (merlin-menu-map (make-sparse-keymap))
         (merlin-show-type-map (make-sparse-keymap)))
     (define-key merlin-map (kbd "C-c <C-return>") 'merlin-to-point)
-    (define-key merlin-map (kbd "C-c l") 'merlin-use)
-    (define-key merlin-map (kbd "C-c r") 'merlin-restart-process)
     (define-key merlin-map (kbd "C-c C-x") 'merlin-error-next)
     (define-key merlin-map (kbd "C-c C-l") 'merlin-locate)
     (when (featurep 'auto-complete)

(defun merlin-locate-pure (ident)
  "Locate the identifier IDENT at point."
  (merlin-sync-to-point)
  (let* ((result (merlin-send-command
             (list 'locate (substring-no-properties ident)
                   'at (merlin-unmake-point (point))))))
    (if (and result (listp result))
        (merlin-goto-file-and-point result)
      (message "%s not found." ident))))

(defun merlin-locate ()
  "Locate the identifier under point"

;; PROCESS MANAGEMENT ;;
;;;;;;;;;;;;;;;;;;;;;;;;

(defun lookup-default (key list &optional default)
  "Lookup KEY in LIST which a list of pairs. If it not found,
return DEFAULT or the value associated to KEY otherwise."
  (let ((v (assoc key list)))
    (if v (cdr v) 
      default)))

    
(defun merlin-instance-buffer-name (name)
  "Return the buffer name corresponding to the merlin instance NAME."
  (format "*merlin (%s)*" name))

(defun merlin-process-buffer ()
  "Return the process buffer of the current buffer."
  (get-buffer (merlin-instance-buffer-name merlin-instance)))

(defun merlin-process ()
  "Return the process of the current buffer."
  (buffer-local-value 'merlin-process (merlin-process-buffer)))

(defun merlin-last-user ()
  "Return the last user of the process of the current buffer."
  (buffer-local-value 'merlin-process-last-user (merlin-process-buffer)))

(defun merlin-start-process (flags &optional configuration)
  "Start the merlin process by fetching the information inside CONFIGURATION. FLAGS contains the list of flags to give merlin.
   CONFIGURATION is an association list with the following keys:
- `extra-flags': extra flags to give merlin

- `command': command to run

- `env': list of strings (of the shape VARIABLE=FOO) (see
`process-environment') that will be prepended to the environment of merlin

- `name': the name of the instance."
  (let* ((command (lookup-default 'command configuration merlin-command))
        (extra-flags (lookup-default 'flags configuration nil))
        (name (lookup-default 'name configuration "default"))
        (environment (lookup-default 'env configuration nil))
        (buffer-name (merlin-instance-buffer-name name)))
    (message "Starting merlin instance: %s (binary=%s)." name command)
    (setq merlin-instance name)
    (when (not (merlin-process-started-p name))
      (let* ((buffer (get-buffer-create buffer-name)) 
             (process-environment (append environment process-environment))
             (p (apply #'start-file-process "merlin" buffer-name
                       command `("-protocol" "sexp" . ,(append extra-flags flags)))))
        (with-current-buffer buffer
          (set-process-query-on-exit-flag p nil)
          (setq merlin-process p)
          (setq merlin-instance name)
          (setq merlin-process-queue (tq-create p)))
        p))))

(defun merlin-toggle-view-errors ()
  "Toggle the viewing of errors in the buffer."
