 (defun merlin-debug (s)
   "Output S if the variable `merlin-debug' is non-nil on the process buffer
 associated to the current buffer."
-  (with-current-buffer (merlin-get-process-buffer-name)
+  (with-current-buffer merlin-buffer-name
     (goto-char (point-max))
     (insert s)))
 

        (delete-overlay merlin-lock-zone-margin-overlay))
      (when merlin-highlight-overlay
        (delete-overlay merlin-highlight-overlay))
      ;;(merlin-error-delete-overlays)
      (merlin-process-remove-user))))

(defun merlin-kill-buffer-hook ()
  "Release merlin resources associated with the buffer."
  (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-after-save
                      nil 'make-it-local)
            (merlin-error-start-timer)))

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

(provide 'merlin)
;;; merlin.el ends here


(defun merlin-process-dead-p ()
  "Return non-nil if merlin process is dead."
  (and merlin-process
       (not (equal (process-status merlin-process) 'run))))

(defun merlin-lighter ()
  "Return the lighter for merlin which indicates the status of merlin process."
