Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created September 8, 2011 06:01
Show Gist options
  • Save mizchi/1202739 to your computer and use it in GitHub Desktop.
Save mizchi/1202739 to your computer and use it in GitHub Desktop.
emacsのcoffee-modeにjs2coffeeする関数を加えるパッチ
--- coffee-mode.el 2011-09-08 14:52:36.000000000 +0900
+++ my-coffee-mode.el 2011-09-08 14:54:21.000000000 +0900
@@ -99,6 +99,12 @@
: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 +240,23 @@
(funcall coffee-js-mode)
(goto-char (point-min)))
+
+(defun coffee-js2coffee-region (start end)
+ "Compiles a region and displays the JS in another 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment