Last active
December 24, 2015 00:09
-
-
Save stesie/6715020 to your computer and use it in GitHub Desktop.
Little helper for GNU Emacs to "karma run"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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