 (require 'merlin)
 
 ;; lists of different outline items
-(defvar-local value-list nil)
-(defvar-local type-list nil)
-(defvar-local exception-list nil)
+(defvar-local merlin-imenu--value-list nil)
+(defvar-local merlin-imenu--type-list nil)
+(defvar-local merlin-imenu--exception-list nil)
 
 (defun merlin-imenu-compute-position (line col)
   "Get location of the item."

  "Create data for imenu using the merlin outline feature."
  (interactive)
  ;; Reset local vars
  (setq value-list nil
        type-list nil
        exception-list nil)
  ;; Read outline tree
  (merlin-imenu-parse-outline "" (merlin/call "outline"))
  (let ((index nil))
    (when value-list (push (cons "Value" value-list) index))
    (when exception-list (push (cons "Exception" exception-list) index))
    (when type-list (push (cons "Type" type-list) index))
    index))

;; enable Merlin to use the merlin-imenu module

           (position (merlin-imenu-compute-position line col))
           (marker (cons entry (set-marker (make-marker) position))))
      (cond ((string= kind "Value")
             (setq merlin-imenu--value-list (cons marker merlin-imenu--value-list)))
            ((string= kind "Type")
             (setq merlin-imenu--type-list (cons marker merlin-imenu--type-list)))
            ((string= kind "Exn")
             (setq merlin-imenu--exception-list (cons marker merlin-imenu--exception-list))))
      (when sub-trees
        (merlin-imenu-parse-outline (concat prefix entry ".") sub-trees)))))

