 	(substring base-name (match-beginning 1) (match-end 1))
       base-name)))
 
+;;; Return the module name of the file
+;;;     /tmp/foo/src/x.erl        --> x
+;;;     /tmp/foo/test/x_tests.erl --> x_tests
+(defun erlang-eunit-module-name (file-path)
+  (interactive)
+  (file-name-sans-extension (file-name-nondirectory file-path)))
+
 ;;; Return the directory name which is common to both src and test
 ;;;     /tmp/foo/src/x.erl        --> /tmp/foo
 ;;;     /tmp/foo/test/x_tests.erl --> /tmp/foo

	   (if (file-readable-p test-filename)
	       (erlang-eunit-compile-file test-filename)
	     t)
	   (erlang-eunit-run-tests)))))

(defun erlang-eunit-compile-file (file-path)
  (if (file-readable-p file-path)

;;; Key bindings
;;;====================================================================

(defconst erlang-eunit-key-bindings
  '(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window)
    ("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests)
    ("\C-c\C-ej" erlang-eunit-compile-and-run-current-test)))

(defun erlang-eunit-add-key-bindings ()
  (dolist (binding erlang-eunit-key-bindings)
    (erlang-eunit-bind-key (car binding) (cadr binding))))

(defun erlang-eunit-bind-key (key function)
  (erlang-eunit-ensure-keymap-for-key key)
  (local-set-key key function))

(defun erlang-eunit-ensure-keymap-for-key (key-seq)
  (let ((prefix-keys (butlast (append key-seq nil)))
