Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

cygwin support #105

Merged
merged 1 commit into from

2 participants

@jkdufair

Hi Phil -

I believe this will allow jack-in to work with cygwin as well as linux/mac. Let me know if you see any issues.

@tavisrudd tavisrudd merged commit 9ab47be into technomancy:master
@tavisrudd
Collaborator

Works for me on Linux.

@jkdufair
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. @jkdufair

    cygwin support

    jkdufair authored
This page is out of date. Refresh to see the latest.
Showing with 32 additions and 7 deletions.
  1. +7 −5 lein-swank/src/leiningen/jack_in.clj
  2. +25 −2 src/swank/util/sys.clj
View
12 lein-swank/src/leiningen/jack_in.clj
@@ -1,7 +1,8 @@
(ns leiningen.jack-in
(:require [clojure.java.io :as io]
[clojure.string :as string]
- [leiningen.swank :as swank])
+ [leiningen.swank :as swank]
+ [swank.util.sys :as util])
(:import (java.security MessageDigest)))
(def ^:private payloads-file-name "swank_elisp_payloads.clj")
@@ -23,10 +24,11 @@
(let [feature (second (re-find #".*/(.*?).el$" resource))
checksum (subs (hex-digest resource) 0 8)
filename (format "%s-%s" feature checksum)
- basename (-> (System/getProperty "user.home")
- (io/file ".emacs.d" "swank" filename)
- (.getAbsolutePath)
- (.replaceAll "\\\\" "/"))
+ basename (util/universal-path
+ (-> (util/preferred-user-home-path)
+ (io/file ".emacs.d" "swank" filename)
+ (.getAbsolutePath)
+ (.replaceAll "\\\\" "/")))
elisp (str basename ".el")
bytecode (str basename ".elc")
elisp-file (io/file elisp)]
View
27 src/swank/util/sys.clj
@@ -1,4 +1,5 @@
-(ns swank.util.sys)
+(ns swank.util.sys
+ (:import (java.io BufferedReader InputStreamReader)))
(defn get-pid
"Returns the PID of the JVM. This is largely a hack and may or may
@@ -9,5 +10,27 @@
(System/getProperty "pid")))
{:tag String})
+(defn cmd [p]
+ (.. Runtime getRuntime (exec (str p))))
+
+(defn cmdout [o]
+ (let [r (BufferedReader.
+ (InputStreamReader. (.getInputStream o)))]
+ (line-seq r)))
+
+;; would prefer (= (System/getenv "OSTYPE") "cygwin")
+;; but clojure's java not in cygwin env
+(defn is-cygwin? []
+ (not= nil (try (cmdout (cmd "cygpath c:\\")) (catch Exception e))))
+
+(defn universal-path [path]
+ (if (is-cygwin?)
+ (first (cmdout (cmd (str "cygpath " path))))
+ path))
+
+(defn preferred-user-home-path []
+ (or (System/getenv "HOME")
+ (System/getProperty "user.home")))
+
(defn user-home-path []
- (System/getProperty "user.home"))
+ (universal-path (preferred-user-home-path)))
Something went wrong with that request. Please try again.