                            )))
 
 (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
 

  (interactive)
  (let ((list
         (mapcar
          '(lambda (obj)
             (cons
              (cdr (assoc 'type obj))
              (merlin-make-bounds obj)))
          (elt
               (merlin-is-return
                (merlin-send-command "type" (list "enclosing" (merlin-unmake-point (point)))))
               1))))
    (setq merlin-enclosing-types list)

  (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook))
                                      
(defun merlin-kill-all-processes ()
  "Kill all the remaining buffers containing merlin processes."
  (interactive)
  (mapc (lambda (p)
          (with-current-buffer (process-buffer p)
            (merlin-kill-process)))))

(provide 'merlin)
