Skip to content

Instantly share code, notes, and snippets.

@stesie
Last active December 24, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stesie/6715020 to your computer and use it in GitHub Desktop.
Save stesie/6715020 to your computer and use it in GitHub Desktop.
Little helper for GNU Emacs to "karma run"
(require 'ansi-color)
(defvar karma-buffer
"*karma-node-specs-buffer*")
(defun karma-compile ()
"Run Karma"
(interactive)
(shell-command "karma run" (get-buffer-create karma-buffer))
(display-buffer karma-buffer)
(with-current-buffer karma-buffer
(ansi-color-apply-on-region (point-min) (point-max))
(save-excursion
(while (re-search-forward "^.*\n\\[1A\\[2K" nil t)
(replace-match "" nil nil)
(beginning-of-buffer)))))
;; bind to key (M-r) in js-mode, adapt to your liking
(add-hook 'js-mode-hook
(lambda ()
(local-set-key (kbd "M-r") 'karma-compile)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment