      (mapcar (lambda (e) (car e)) erlang-error-regexp-alist))))
 
 (defun erlang-eunit-is-compilation-warning ()
-  (erlang-eunit-string-match-p 
+  (erlang-eunit-string-match-p
    "[0-9]+: Warning:"
    (buffer-substring (line-beginning-position) (line-end-position))))
 

                ((erlang-eunit-test-generator-p test-name)
                 (format "eunit:test({generator, %s, %s}%s)."
                         module-name test-name (erlang-eunit-opts)))
                (t (format "%% WARNING: '%s' is not a test function" test-name)))))
    (erlang-eunit-inferior-erlang-send-command command)))

;;; Run EUnit tests for the current module

         (command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts))))
    (erlang-eunit-inferior-erlang-send-command command)))

(defun erlang-eunit-cover-compile ()
  "Cover compile current module."
  (interactive)
  (let* ((erlang-compile-extra-opts
          (append (list 'debug_info) erlang-compile-extra-opts))
         (module-name
          (erlang-add-quotes-if-needed
           (erlang-eunit-module-name buffer-file-name)))
         (compile-command
          (format "cover:compile_beam(%s)." module-name)))
    (erlang-compile)
    (if (erlang-eunit-last-compilation-successful-p)
        (erlang-eunit-inferior-erlang-send-command compile-command))))

(defun erlang-eunit-analyze-coverage ()
  "Analyze the data collected by cover tool for the module in the
current buffer.

Assumes that the module has been cover compiled prior to this
call.  This function will do two things: print the number of
covered and uncovered functions in the erlang shell and display a
new buffer called *<module name> coverage* which shows the source
code along with the coverage analysis results."
  (interactive)
  (let* ((module-name     (erlang-add-quotes-if-needed
                           (erlang-eunit-module-name buffer-file-name)))
         (tmp-filename    (make-temp-file "cover"))
         (analyze-command (format "cover:analyze_to_file(%s, \"%s\"). "
                                  module-name tmp-filename))
         (buf-name        (format "*%s coverage*" module-name)))
    (erlang-eunit-inferior-erlang-send-command analyze-command)
    ;; The purpose of the following snippet is to get the result of the
    ;; analysis from a file into a new buffer (or an old, if one with
    ;; the specified name already exists).  Also we want the erlang-mode
    ;; *and* view-mode to be enabled.
    (save-excursion
      (let ((buf (get-buffer-create (format "*%s coverage*" module-name))))
        (set-buffer buf)
        (setq buffer-read-only nil)
        (insert-file-contents tmp-filename nil nil nil t)
        (if (= (buffer-size) 0)
            (kill-buffer buf)
          ;; FIXME: this would be a good place to enable (emacs-mode)
          ;;        to get some nice syntax highlighting in the
          ;;        coverage report, but it doesn't play well with
          ;;        flymake.  Leave it off for now.
          (view-buffer buf))))
    (delete-file tmp-filename)))

(defun erlang-eunit-compile-and-run-current-test ()
  "Compile the source and test files and run the current EUnit test.

