   (when merlin-mode
     (merlin-process-remove-user)))
 
+(defun merlin-after-save ()
+  (when merlin-error-after-save (merlin-to-end)))
+
 (add-hook 'merlin-mode-hook
           (lambda ()
-            (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook nil 'make-it-local)
-            (add-hook 'after-save-hook 'merlin-to-end nil 'make-it-local)
+            (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook
+                      nil 'make-it-local)
+            (add-hook 'after-save-hook 'merlin-after-save
+                      nil 'make-it-local)
             (add-hook 'pre-command-hook
                       'merlin-show-current-error nil 'make-it-local)
             (add-hook 'post-command-hook

                                           merlin-margin-error-string
                                           compilation-error-face))
              overlay)))
         (errors   (mapcar err-point errors))
         (overlays (mapcar err-overlay errors)))
    (setq merlin-pending-errors errors)
    (setq merlin-pending-errors-overlays overlays)))

(defun merlin-error-check (view-errors-p)
  "Check for errors.

         (errors (if merlin-report-warnings errors
                   (delete-if (lambda (e) (merlin-error-warning-p (cdr (assoc 'message e))))
                              errors))))
    (if (not errors) (when view-errors-p (message "ok"))
      (progn
        (merlin-error-display-in-margin errors)
        (when view-errors-p
          (message "(%d pending errors, use %s to jump)"
                   (length errors)
                   (substitute-command-keys "\\[merlin-error-next]")))))))
