Browse files

Add support for Cygwin-style absolute paths, which makes using the fi…

…le compilation feature of CoffeeScript mode possible on Windows systems where Node.js is compiled with Cygwin
  • Loading branch information...
1 parent 27df14a commit 2d489a8dcd54fd6adfd97d1ea0fd6160768d7a27 @semperos semperos committed Aug 5, 2011
Showing with 19 additions and 1 deletion.
  1. +19 −1 coffee-mode.el
@@ -109,6 +109,16 @@ path."
:type 'list
:group 'coffee)
+(defcustom coffee-cygwin-mode t
+ "For Windows systems, add support for Cygwin-style absolute paths."
+ :type 'boolean
+ :group 'coffee)
+(defcustom coffee-cygwin-prefix "/cygdrive/C"
+ "The prefix with which to replace the drive-letter for your Windows partition, e.g. 'C:' would be replaced by '/c/cygdrive'."
+ :type 'string
+ :group 'coffee)
(defcustom coffee-compiled-buffer-name "*coffee-compiled*"
"The name of the scratch buffer used when compiling CoffeeScript."
:type 'string
@@ -315,9 +325,17 @@ For detail, see `comment-dwim'."
(let ((deactivate-mark nil) (comment-start "#") (comment-end ""))
(comment-dwim arg)))
+(defun coffee-cygwin-path (expanded-file-name)
+ "Given an expanded file name, derive the absolute Cygwin path based on `coffee-cygwin-prefix'."
+ (replace-regexp-in-string "^[a-zA-Z]:" coffee-cygwin-prefix expanded-file-name t))
(defun coffee-command-compile (file-name)
"The `coffee-command' with args to compile a file."
- (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list file-name)) " "))
+ (let ((full-file-name (if (and (equal system-type 'windows-nt)
+ coffee-cygwin-mode)
+ (coffee-cygwin-path (expand-file-name file-name))
+ (expand-file-name file-name))))
+ (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list full-file-name)) " ")))
;; imenu support

0 comments on commit 2d489a8

Please sign in to comment.