Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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