 
 (defun merlin-ac-prefix ()
   "Retrieve the prefix for completion with merlin."
-  (car (merlin--completion-bounds)))
+  (let* ((bounds (merlin--completion-bounds))
+         (start  (car-safe bounds))
+         (end    (cdr-safe bounds)))
+    (if (and bounds merlin-ac-prefix-size
+             (< (- start end) merlin-ac-prefix-size))
+        nil
+      bounds)))
 
 (defun merlin-ac-fetch-type ()
   "Prints the type of the selected candidate"

  merlin-ac-cache)

(defvar merlin-ac-source
  (if merlin-ac-prefix-size
  `((init . merlin-ac-source-init)
    (candidates . merlin-auto-complete-candidates)
    (action . merlin-ac-fetch-type)
    (prefix . ,merlin-ac-prefix-size))
  '((init . merlin-ac-source-init)
    (candidates . merlin-auto-complete-candidates)
    (action . merlin-ac-fetch-type)
    (prefix . merlin-ac-prefix))))

(when (featurep 'auto-complete)
  (eval '(ac-define-source "merlin" merlin-ac-source)))

                      (merlin--completion-format-entry entry)
                      (cdr (assoc 'kind entry))
                      (cdr (assoc 'info entry))))
              entries))))

(defun merlin--completion-lookup (string state)
  "Lookup the entry STRING inside the completion table."
