 
 (defun merlin-error-delete-overlays ()
   "Remove margin error overlays."
-  (mapc #'delete-overlay merlin-pending-errors-overlays)
-  (setq merlin-pending-errors-overlays nil))
+  (remove-overlays nil nil 'merlin-kind 'error))
 
 (defun merlin-error-warning-p (msg)
   "Tell if the message MSG is a warning."

(defun merlin--kill-overlapping-errors (start end)
  "Kill any pending errors that overlap the region START..END."
  ;; fixme: factor out common bits with kill-if-edited
  (loop for err in merlin-pending-errors
	for overlay in merlin-pending-errors-overlays
	if (and (>= (overlay-start overlay) start)
		(<= (overlay-end overlay) end))
	  do (delete-overlay overlay)
	else
	  collect err into surviving-errors
	  and collect overlay into surviving-overlays
	finally (setq merlin-pending-errors surviving-errors
		      merlin-pending-errors-overlays surviving-overlays)))

(defun merlin-completion-at-point ()
  "Perform completion at point with merlin."

(defvar merlin-pending-errors nil
  "Pending errors.")
(make-variable-buffer-local 'merlin-pending-errors)

(defvar merlin-highlight-overlay nil
  "Merlin overlay used for highlights.")
