Permalink
Browse files

add coffee-js2coffee-replace-region

  • Loading branch information...
1 parent fde6c89 commit 2c204efae48ffb866fe0cfb050c19608261efa6b @mizchi mizchi committed with Sep 8, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 coffee-mode.el
View
@@ -99,6 +99,13 @@ path."
:type 'string
:group 'coffee)
+(defcustom js2coffee-command "js2coffee"
+ "The js2coffee command used for evaluating code. Must be in your
+path."
+ :type 'string
+ :group 'coffee)
+
+
(defcustom coffee-args-repl '("-i")
"The command line arguments to pass to `coffee-command' to start a REPL."
:type 'list
@@ -234,6 +241,21 @@ If FILENAME is omitted, the current buffer's file name is used."
(funcall coffee-js-mode)
(goto-char (point-min)))
+(defun coffee-js2coffee-replace-region (start end)
+ "Replace JS to coffee in current buffer."
+ (interactive "r")
+
+ (let ((buffer (get-buffer coffee-compiled-buffer-name)))
+ (when buffer
+ (kill-buffer buffer)))
+
+ (call-process-region start end
+ js2coffee-command nil
+ (current-buffer)
+ )
+ (delete-region start end)
+ )
+
(defun coffee-show-version ()
"Prints the `coffee-mode' version."
(interactive)

0 comments on commit 2c204ef

Please sign in to comment.