                            )))
 
 (defun merlin-create-overlay (var bounds face timer)
-  "Creates an overlay in the current buffer starting at `start', ending at `end',
-using `face' and storing it in `var'. If `timer' is non-nil, the overlay is to disappear after `timer' seconds
-`timer' is a string that can be understood by `run-at-time' (eg. \"1 sec\")"
-  (if (symbol-value var) (delete-overlay (symbol-value var)))
-  (set var (make-overlay (car bounds) (cdr bounds)))
-  (overlay-put (symbol-value var) 'face face)
-  (if timer
-      (run-at-time timer nil `(lambda ()
-                                (delete-overlay ,var)
-                                (set ,var nil)))))
+  "Create an overlay on BOUNDS (of the form (START . END)).
+Give it FACE and store it in VAR. If TIMER is non-nil, the overlay is to disappear after TIMER seconds."
+  (let ((ol (or (symbol-value var)
+                (set var (make-overlay (point) (point))))))
+    (move-overlay ol (car bounds) (cdr bounds))
+    (overlay-put ol 'face face)
+    (if timer
+        (run-at-time timer nil #'delete-overlay ol))))
       
 ;; PROCESS MANAGEMENT
 


;; COMPLETION
(defun merlin-extract-complete (prefix l)
  "Parses and format completion results"
  (mapcar `(lambda (c) 
             (if merlin-completion-types
                 (popup-make-item (concat prefix (cdr (assoc 'name c)))
                                  :symbol (format "%c" (car (string-to-list (cdr (assoc 'kind c)))))
                                  :summary (cdr (assoc 'desc c)))
               (cdr (assoc 'name c))))
	  (append l nil)))

(defun merlin-complete-identifier (ident)

  (string-match "^Warning" msg))

(defun merlin-display-errors-in-margin (errors)
  "Given a list of ERRORS, put annotations in the margin corresponding to them."
  (merlin-delete-error-overlays)
  (setq merlin-pending-errors (append errors nil))
  (setq merlin-pending-errors-overlays 
        (mapcar (lambda (err)
                  (let ((overlay (make-overlay
                                  (merlin-make-point (cdr (assoc 'start err)))
                                  (merlin-make-point (cdr (assoc 'end err))))))
                    (if (merlin-warning-p (cdr (assoc 'message err)))
                        (merlin-put-margin-overlay overlay "?" compilation-warning-face)
                      (merlin-put-margin-overlay overlay "!" compilation-error-face))
                     
                    overlay)) 
                errors))
  (message "(pending errors, use %s to jump)"
           (substitute-command-keys "\\[merlin-next-error]")))

