seanmcl avatar seanmcl committed f665136

omake-mode on OSX

Comments (0)

Files changed (4)

 new stuff
-- Working on OSX
+- Got omake-mode working on OSX
 bug fixes
+- stopping server from the command line left connection objects alive


 ;; Shell                                                                      ;;
+(defvar Shell.readlink-cmd "readlink")
+(defvar Shell.mkdir-cmd "mkdir")
+(defvar Shell.dirname-cmd "dirname")
+(defvar Shell.basename-cmd "basename")
+(case system-type
+  (darwin
+   (setq Shell.readlink-cmd "greadlink"
+         Shell.mkdir-cmd "gmkdir"
+         Shell.dirname-cmd "gdirname"
+         Shell.basename-cmd "gbasename"))
+  (gnu/linux nil)
+  (t
+   (message "WARNING: Unsupported OS: %s.  System calls may not work." system-type)))
 (defun Shell.readlink (path)
   "Canonize the path by eliminating symlinks and dots"
   (if (not path) nil
     (let ((res (String.strip-newlines
-                (shell-command-to-string (format "readlink -f %s" path)))))
+                (shell-command-to-string (format "%s -f %s" Shell.readlink-cmd path)))))
       (if (equal res "") nil res))))
 ;; (Shell.readlink "/usr/../home")
 ;; (Shell.readlink "/usr/local//share")
 (defun Shell.dirname (path)
   (if (not path) nil
     (let ((res (String.strip-newlines
-                (shell-command-to-string (format "dirname %s" path)))))
+                (shell-command-to-string (format "%s %s" Shell.dirname-cmd path)))))
       (if (equal res "") nil res))))
 ;; (Shell.dirname nil)
 ;; (Shell.dirname "/")
 (defun Shell.basename (path)
   (if (not path) nil
     (let ((res (String.strip-newlines
-                (shell-command-to-string (format "basename %s" path)))))
+                (shell-command-to-string (format "%s %s" Shell.basename-cmd path)))))
       (if (equal res "") nil res))))
 ;; (Shell.basename "/a/b/c")
 ;; (Shell.basename "/")


 OCAMLOPT=ocamlfind ocamlopt -thread -w @a-4-7-9-29-28 \
         -pp $(PP) \
-        -strict-sequence -annot -inline 20 -nodynlink -g \
+        -strict-sequence -inline 20 -nodynlink -g \
 	-package core -package core_extended -package async -package pcre \
 FILES=          \


   module Out_channel = Out_channel
   module Result = Result
   module Sexp = Sexp
-  module Shell = Core_extended.Std.Shell
   module Stringable = Stringable
   module Sys = Sys
   module Time = Time
 module Process = Process
+module Shell = struct
+  include Core_extended.Std.Shell
+  (* Shell.mkdir doesn't work on OSX.  This should work on both. *)
+  let mkdir ?p ?perm file =
+    let p = match p with None -> "" | Some () -> "-p" in
+    let perm = match perm with None -> "" | Some d -> sprintf "-m %o" d in
+    let n = Sys.command (sprintf "mkdir %s %s %s" p perm file) in
+    if n = 0 then () else failwithf "Shell.mkdir: failed with exit code %d" n ()
 module Ashell = struct
   let run cmd args = (fun () -> cmd args)
   let run_lines cmd args = (fun () -> Shell.run_lines cmd args)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.