Permalink
Browse files

Add support for coffee --watch, and in process also add function for …

…running coffee with arbitrary arguments within Emacs
  • Loading branch information...
1 parent b4270de commit 0b06b86d1f153131e1b811eaa784d4fb101096d7 @semperos semperos committed with Aug 16, 2011
Showing with 19 additions and 0 deletions.
  1. +19 −0 coffee-mode.el
View
@@ -132,6 +132,11 @@ to the error, of course."
:type 'boolean
:group 'coffee)
+(defcustom coffee-watch-buffer-name "*coffee-watch*"
+ "The name of the scratch buffer used when using the --watch flag with CoffeeScript."
+ :type 'string
+ :group 'coffee)
+
(defvar coffee-mode-hook nil
"A hook for you to run your own code when the mode is loaded.")
@@ -235,6 +240,13 @@ If FILENAME is omitted, the current buffer's file name is used."
(interactive)
(browse-url "http://github.com/defunkt/coffee-mode"))
+(defun coffee-watch (dir-or-file)
+ "Run `coffee-run-cmd' with the --watch flag enabled for a directory or file"
+ (interactive "fDirectory or File: ")
+ (let ((coffee-compiled-buffer-name coffee-watch-buffer-name)
+ (args (mapconcat 'identity (append coffee-args-compile (list "--watch" (expand-file-name dir-or-file))) " ")))
+ (coffee-run-cmd args)))
+
;;
;; Menubar
;;
@@ -356,6 +368,13 @@ For detail, see `comment-dwim'."
(let ((full-file-name (coffee-universal-path file-name)))
(mapconcat 'identity (append (list coffee-command) coffee-args-compile (list full-file-name)) " ")))
+(defun coffee-run-cmd (args)
+ "Given an arbitrary set of arguments for the `coffee-command', compile the command and show output in a custom compilation buffer."
+ (interactive "sArguments: ")
+ (let ((compilation-buffer-name-function (lambda (this-mode)
+ (generate-new-buffer-name coffee-compiled-buffer-name))))
+ (compile (concat coffee-command " " args))))
+
;;
;; imenu support
;;

0 comments on commit 0b06b86

Please sign in to comment.