Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for Cygwin-style absolute paths on Windows Systems #42

Merged
merged 2 commits into from

2 participants

@semperos

This pull request addresses Issue #37

Obviously it is customary to run CoffeeScript under Node.js. For Windows users, it is common to compile Node.js with Cygwin in order to use CoffeeScript. However, Cygwin expects it's own style of absolute paths (prefixed with /cygdrive/C), which of course expand-file-name does not expand to. Given these restrictions, at the present time coffee-mode's file compilation functionality does not work on Windows.

I've implemented three things:

  • A coffee-cygwin-mode customizable var, for enabling/disabling support for Cygwin-style paths on Windows for CoffeeScript commands
  • A coffee-cygwin-prefix customizable var, to allow people to set /cygdrive/C to whatever their Cygwin expects to see (dependent on installation)
  • A coffee-cygwin-path function, which given an expanded file name will return a Cygwin-style absolute path + file name

Finally, I tweaked coffee-command-compile to leverage these settings when the system-type is windows-nt.

Without these changes, this mode's file compilation functionality does not work on Windows for the "canonical" setup of CoffeeScript on Node.js.

semperos added some commits
@semperos semperos 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
2d489a8
@semperos semperos Create function to encapsulate logic of supporting Cygwin-based Windo…
…ws paths, use in coffee-command-compile
e8fd539
@semperos

Second commit encapsulates the system check and Cygwin path support in a single function, coffee-universal-path. Returns the regular expanded file name for all other systems, like this mode already does.

@defunkt defunkt merged commit 58c1401 into defunkt:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 5, 2011
  1. @semperos

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

    semperos authored
    …le compilation feature of CoffeeScript mode possible on Windows systems where Node.js is compiled with Cygwin
  2. @semperos

    Create function to encapsulate logic of supporting Cygwin-based Windo…

    semperos authored
    …ws paths, use in coffee-command-compile
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 1 deletion.
  1. +24 −1 coffee-mode.el
View
25 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,22 @@ 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-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."
- (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list file-name)) " "))
+ (let ((full-file-name (coffee-universal-path file-name)))
+ (mapconcat 'identity (append (list coffee-command) coffee-args-compile (list full-file-name)) " ")))
;;
;; imenu support
Something went wrong with that request. Please try again.