Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TDD functions for emacs
(global-set-key (kbd "C-c C-r") 'run-mocha)
(defun run-mocha()
"Runs all the tests in the current buffer"
(let* (command result exit-value)
(setq command (concat "mocha -r should " (buffer-name)))
(setq exit-value (shell-command command))
(color-modeline exit-value)))
(defun color-modeline(exit-value)
"Colors the modeline, green success red failure"
(let (test-result-color)
(if (= exit-value 0)
(setq test-result-color "Green")
(setq test-result-color "Red"))
(set-face-background 'modeline test-result-color)
(run-at-time "1 sec" nil 'no-color-modeline)))
(defun no-color-modeline()
"No color for the modeline"
(set-face-background 'modeline nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment