From 2d489a8dcd54fd6adfd97d1ea0fd6160768d7a27 Mon Sep 17 00:00:00 2001 From: Daniel Gregoire Date: Thu, 4 Aug 2011 23:51:54 -0400 Subject: [PATCH 1/2] Add support for Cygwin-style absolute paths, which makes using the file compilation feature of CoffeeScript mode possible on Windows systems where Node.js is compiled with Cygwin --- coffee-mode.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/coffee-mode.el b/coffee-mode.el index 5162c2a..ee72b66 100644 --- a/coffee-mode.el +++ b/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 From e8fd539ec863e217f0505f81dabbd73cf67b55a9 Mon Sep 17 00:00:00 2001 From: Daniel Gregoire Date: Fri, 5 Aug 2011 16:22:30 -0400 Subject: [PATCH 2/2] Create function to encapsulate logic of supporting Cygwin-based Windows paths, use in coffee-command-compile --- coffee-mode.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/coffee-mode.el b/coffee-mode.el index ee72b66..68e3721 100644 --- a/coffee-mode.el +++ b/coffee-mode.el @@ -329,12 +329,17 @@ For detail, see `comment-dwim'." "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-universal-path (file-name) + "Handle different paths for different OS configurations for CoffeeScript" + (let ((full-file-name (expand-file-name file-name))) + (if (and (equal system-type 'windows-nt) + coffee-cygwin-mode) + (coffee-cygwin-path full-file-name) + full-file-name))) + (defun coffee-command-compile (file-name) "The `coffee-command' with args to compile a file." - (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)))) + (let ((full-file-name (coffee-universal-path file-name))) (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list full-file-name)) " "))) ;;