Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
The tiniest possible skewer-mode extension for coffeescript support.
;;; skewer-coffee.el --- skewer support for live-interactive Coffeescript
(defun skewer-coffee-eval (coffee-code)
"Requests the browser to evaluate a coffeescipt string."
;; XXX should escape double quote characters
(skewer-eval (concat "CoffeeScript.eval(\""
(s-replace "\n" "\\n" (s-trim coffee-code))
(defun skewer-coffee-eval-region ()
"Sends the coffeescript code the region encloses, or -- if
there's no active region -- sends the current line."
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(thing-at-point 'line))))
(defun skewer-coffee-eval-defun ()
"Evaluates the current 'sentence', which is usually a complete function."
(skewer-coffee-eval (thing-at-point 'sentence)))
(defun skewer-coffee-eval-buffer ()
"Evaluates the current buffer as CoffeeScript."
(skewer-coffee-eval (buffer-substring-no-properties (point-min) (point-max))))
(defvar skewer-coffee-mode-map
(let ((map (make-sparse-keymap)))
(prog1 map
(define-key map (kbd "C-x C-e") 'skewer-coffee-eval-region)
(define-key map (kbd "C-M-x") 'skewer-coffee-eval-defun)
(define-key map (kbd "C-c C-k") 'skewer-coffee-eval-buffer)))
"Keymap for skewer-coffee-mode.")
(define-minor-mode skewer-coffee-mode
"Minor mode for interactively loading coffeescript forms."
:lighter " skewer-coffee"
:keymap skewer-coffee-mode-map
:group skewer)
(provide 'skewer-coffee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.