Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

compilation commands

  • Loading branch information...
commit 7557530999e904ebc7d20023ebf093f6e5cc5925 1 parent 97a1001
@defunkt authored
Showing with 40 additions and 4 deletions.
  1. +40 −4 coffee-mode.el
View
44 coffee-mode.el
@@ -1,6 +1,42 @@
+;;
;; Major thanks to http://xahlee.org/emacs/elisp_syntax_coloring.html
;; the instructions.
+;;
+;; Commands
+;;
+
+(defvar coffee-command "coffee"
+ "The CoffeeScript command used for evaluating code. Must be in your
+path.")
+
+(defvar coffee-js-mode 'js2-mode
+ "The mode to use when viewing compiled JavaScript.")
+
+(defvar coffee-compiled-buffer-name "*coffee-compiled*"
+ "The name of the scratch buffer used when compiling CoffeeScript.")
+
+(defun coffee-compile-buffer ()
+ "Compiles the current buffer and displays the JS in the other buffer."
+ (interactive)
+ (save-excursion
+ (coffee-compile-region (point-min) (point-max))))
+
+(defun coffee-compile-region (start end)
+ "Compiles a region and displays the JS in the other buffer."
+ (interactive "r")
+
+ (let ((buffer (get-buffer coffee-compiled-buffer-name)))
+ (when buffer
+ (kill-buffer buffer)))
+
+ (call-process-region start end coffee-command nil
+ (get-buffer-create coffee-compiled-buffer-name)
+ nil
+ "-s" "-p" "--no-wrap")
+ (switch-to-buffer-other-frame (get-buffer coffee-compiled-buffer-name))
+ (funcall coffee-js-mode)
+ (beginning-of-buffer))
;;
;; Define Language Syntax
@@ -59,7 +95,6 @@
;; would be highlighted.
))
-
;;
;; Helper Functions
;;
@@ -136,12 +171,13 @@ For detail, see `comment-dwim'."
"coffee-mode"
"Major mode for editing CoffeeScript..."
+ (define-key coffee-mode-map (kbd "A-r") 'coffee-compile-buffer)
+;; (define-key coffee-mode-map (kbd "A-R") 'coffee-execute-line)
+ (define-key coffee-mode-map [remap comment-dwim] 'coffee-comment-dwim)
+
;; code for syntax highlighting
(setq font-lock-defaults '((coffee-font-lock-keywords)))
- ;; modify the keymap
- (define-key coffee-mode-map [remap comment-dwim] 'coffee-comment-dwim)
-
;; perl style comment: "# ..."
(modify-syntax-entry ?# "< b" coffee-mode-syntax-table)
(modify-syntax-entry ?\n "> b" coffee-mode-syntax-table)
Please sign in to comment.
Something went wrong with that request. Please try again.