Commits

seanmcl  committed 8eea99f

compiles with the new core

  • Participants
  • Parent commits cae20a4

Comments (0)

Files changed (8)

+
+new stuff
+=========
+
+- ocp-indent can be used to indent ocaml code.
+
+    https://github.com/OCamlPro/ocp-indent
+
+  Currently only whole-buffer indentation is supported.  To use it, set
+
+    (setq ocaml-indenter 'ocp-indent)
+
+  to use Tuareg's indenter, use
+
+    (setq ocaml-indenter 'tuareg)
+
+  This is in its infancy, but we added a few regression tests so we
+  don't go backwards.
+
+  The code is in omake-mode/ocp-indent.  To run regression tests do
+  cd regressions; ./runtests
+
+- omake-mode works with the new core release, ocaml-core-108.07.00
+
+changes
+=======
+
+- We are using a new repo,
+
+    https://bitbucket.org/seanmcl/ocaml-core-108.07.00-seanmcl
+
+  to build omake-mode both externally and at Jane Street.  This makes
+  problems we faced with installing inotify in the two places easier to handle.
+
+bug fixes
+=========
+
+--------------------------------------------------------------------------------
 
 new stuff
 =========

File ocaml/omake/emacs.ml

   t.writer <- writer
 | None ->
   let t = { pid; writer; watching = Id.Hash_set.create () } in
-  whenever (Writer.close_finished writer >>= fun () -> unregister pid);
+  don't_wait_for (Writer.close_finished writer >>= fun () -> unregister pid);
   Hashtbl.replace table ~key:pid ~data:t
 
 let writer t = t.writer

File ocaml/omake/omake.ml

             add_error_line s;
             Deferred.unit)
     in
-    whenever (iter ());
+    don't_wait_for (iter ());
     event_reader
 end
 
     let span = Time.Span.of_sec 1.0 in
     let stop_ivar = Ivar.create () in
     Clock.every' span ~stop:(Ivar.read stop_ivar) update1;
-    (* whenever (Pipe.iter update_reader ~f:update); *)
+    (* don't_wait_for (Pipe.iter update_reader ~f:update); *)
     (* let update () = *)
-    (*   whenever (Pipe.write update_writer ()); *)
+    (*   don't_wait_for (Pipe.write update_writer ()); *)
     (*   Deferred.unit *)
     (* in *)
     (* update the model *)
           omake_error >>= fun () ->
           update ())
     in
-    whenever (iter ());
+    don't_wait_for (iter ());
     elisp_reader
 end
 
     let state = State.create ~omakeroot_dir in
     let lines = Pipe.map ~f:cleanup_chars reader in
     let (reader, writer) = Pipe.create () in
-    whenever (Pipe.iter lines ~f:(Deferred.List.iter ~f:(Pipe.write writer)));
+    don't_wait_for (Pipe.iter lines ~f:(Deferred.List.iter ~f:(Pipe.write writer)));
     let events = Event.parse_events reader in
     State.handle_events state events
 end

File ocaml/omake/process.ml

   let stdin_text = stdin in
   let process_exited = ref false in
   let kill ~pid = if not !process_exited then term_or_kill pid in
-  In_thread.syscall_exn (fun () ->
+  In_thread.syscall_exn ~name:"omake-mode-process" (fun () ->
     Unix.create_process_env ~prog ~args ~env ?working_dir ())
   >>= fun proc_info ->
     let pid    = proc_info.Unix.Process_info.pid in
        unwelcomed extra complexity. What exactly are we guarding against? *)
     Kill_at_shutdown.register pid;
     let stdin =
-      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stdin ~name:"<stdin>"
+      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stdin (Info.of_string "<stdin>")
     in
     let stdout =
-      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stdout ~name:"<stdout>"
+      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stdout (Info.of_string "<stdout>")
     in
     let stderr =
-      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stderr ~name:"<stderr>"
+      Fd.create Fd.Kind.Fifo proc_info.Unix.Process_info.stderr (Info.of_string "<stderr>")
     in
     let stdin  = Writer.create stdin  in
     let stdout = Reader.create stdout in
         Unix.dup2 ~src:stdin ~dst:Unix.stdin;
         Unix.dup2 ~src:stdout ~dst:Unix.stdout;
         Unix.dup2 ~src:stderr ~dst:Unix.stderr;
-        Unix.execvp ~prog ~args:(Array.of_list (prog::args))
+        UnixLabels.execvp ~prog ~args:(Array.of_list (prog::args))
       with
       | _ ->
         Printf.eprintf "exec failed: %s\n%!" prog;
     create ?kill ~prog ~args ~env () ~f:(fun _pid ~stdin ~stdout ~stderr ->
       Ivar.fill readers (stdout, stderr);
       Writer.close stdin >>= fun () ->
-        Deferred.all_unit [Reader.closed stdout; Reader.closed stderr]
+        Deferred.all_unit [Reader.close_finished stdout; Reader.close_finished stderr]
     )
   in
   upon status (fun ((), status) ->

File ocaml/omake/project.ml

         partial := last;
         Deferred.List.iter ~f:(Pipe.write w) complete)
     in
-    whenever (iter ());
+    don't_wait_for (iter ());
     r
   in
   let elisp_pipe = Omake.parse_omake_output ~omakeroot_dir reader in
   create1 t >>| fun t ->
   kill_when_unwatched t;
   (* start never returns *)
-  whenever (start t);
+  don't_wait_for (start t);
   t
 
 let to_elisp t =

File ocaml/omake/server.ml

   Log.wait ()
   >>= fun () ->
   Log.printf "Starting controller on %s" Files.socket;
-  Tcp.serve_unix ~file:Files.socket ~on_handler_error:`Raise (fun _ reader writer ->
+  Tcp.Server.create ~on_handler_error:`Raise (Tcp.on_file Files.socket)
+    (fun _ reader writer ->
     (* NB: reader and writer are the same file descriptor. *)
-    try_with (fun () ->
-      Reader.read_sexp reader >>= function
-      | `Eof ->
-        Writer.close writer >>= fun () ->
-        Reader.close reader >>= fun () ->
-        failwith "Read error"
-      | `Ok s ->
+      try_with (fun () ->
+        Reader.read_sexp reader >>= function
+        | `Eof ->
+          Writer.close writer >>= fun () ->
+          Reader.close reader >>= fun () ->
+          failwith "Read error"
+        | `Ok s ->
         (* Don't close the reader.  The writer gets saved in the hashtable. *)
-        Log.printf "omake server received: %s" (Sexp.to_string s);
+          Log.printf "omake server received: %s" (Sexp.to_string s);
         (* When Emacs is killed, the server will still be writing messages to
            its writer for a few seconds until the server notices emacs is dead.
            Ignore the pipe failures. *)
-        Writer.set_raise_epipe writer false;
-        Query.handle writer (Query.t_of_sexp s)) >>= function
-    | Ok () -> Deferred.unit
-    | Error exn ->
-      Log.exn exn;
-      Writer.writef writer "%s" (Elisp.error (Exn.to_string exn));
-      Deferred.unit) >>= fun () ->
+          Writer.set_raise_when_consumer_leaves writer false;
+          Query.handle writer (Query.t_of_sexp s)) >>= function
+      | Ok () -> Deferred.unit
+      | Error exn ->
+        Log.exn exn;
+        Writer.writef writer "%s" (Elisp.error (Exn.to_string exn));
+        Deferred.unit) >>= fun _ ->
   (* The server should remain alive until shutdown is called explicitly. *)
   Log.printf "Accepting TCP connections.";
   watch_for_inotify_limit ();
   | `No | `Unknown ->
     failwithf "Missing socket file: %s" file ()
   | `Yes ->
-    Tcp.connect_unix ~file () >>= fun (reader, writer) ->
-    Writer.write writer msg;
-    Pipe.iter (Reader.pipe reader) ~f:(fun s ->
+    Tcp.with_connection (Tcp.to_file Files.socket) (fun reader writer ->
+      Writer.write writer msg;
+      Pipe.iter (Reader.pipe reader) ~f:(fun s ->
       (* Write to the process's stdout *)
-      printf "%s\n" s;
-      Deferred.unit)
+        printf "%s\n" s;
+        Deferred.unit))

File ocaml/omake/std.ml

   end
   module Array = Array
   module Bool = Bool
-  module Service_command = Core_extended.Core_service_command
-  module Command = Core_extended.Core_command
+  module Service_command = Core_extended.Service_command
+  module Command = Core.Command
   module Date = Date
   module Doubly_linked = Doubly_linked
   module Filename = Filename
   let (>>=) = (>>=)
   let (>>|) = (>>|)
   let (>>>) = (>>>)
-  let whenever = whenever
+  let don't_wait_for = don't_wait_for
   let return = return
   let try_with = try_with
   let shutdown = shutdown

File ocaml/omake/top.ml

       name = "omake_server";
       redirect_stdout = `File_append Files.controller;
       redirect_stderr = `File_append Files.controller; }
-    let slot_spec () = Command.Spec.( const slot )
+    let slot_spec () = Command.Spec.( empty +> const slot )
     let main_spec =
       Command.Spec.(
-        step (fun m debug -> if debug then Omake.debug := true; m ~foreground:false) ++
-          flag "-debug" no_arg ~doc:" Print debugging info into [omake-server-log]" )
+        step (fun m debug -> if debug then Omake.debug := true; m ~foreground:false)
+        ++ empty
+        +> flag "-debug" no_arg ~doc:" Print debugging info into [omake-server-log]"
+      )
     let main _ =
       schedule ~quit:false (fun () ->
         at_exit (fun () -> printf "Hello, world!\n");
 
   let stop = Command.basic
     ~summary:"Stop the server"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Stop_server)
 
   let controller = Command.group ~summary:"controller"
 
   let show = Command.basic
     ~summary:"Show the server state"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Show_state)
 
   let ping = Command.basic
     ~summary:"Ping the server"
-    Command.Spec.( flag "-pid" (required int) ~doc:"PID emacs pid"
-                   ++ flag "-version" (required int) ~doc:"INT emacs omake version"
-                   ++ flag "-counter" (required int) ~doc:"INT id"  )
+    Command.Spec.( empty
+                   +> flag "-pid" (required int) ~doc:"PID emacs pid"
+                   +> flag "-version" (required int) ~doc:"INT emacs omake version"
+                   +> flag "-counter" (required int) ~doc:"INT id"  )
     (fun pid version uid ->
       let pid = Pid.of_int pid in
       send (Q.Ping (pid, { Q.version; uid })))
 
   let version = Command.basic
     ~summary:"Print the version so we can sync with the elisp version."
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> Core.Std.printf "%d" Version.version)
 
   let running =
     Command.basic
       ~summary:"return 0 if the controller is listening on the socket, 1 otherwise"
-      Command.Spec.( const () )
+      Command.Spec.( empty +> const () )
       (fun () -> schedule (fun () ->
         (* Send an arbitrary query *)
         try_with (fun () -> Server.connect "Running") >>| function
     Command.basic
       ~summary:"Run on a given file."
       Command.Spec.(
-        flag "-debug" no_arg ~doc:" Print debugging info into [omake-server-log]"
-        ++ anon ("file" %: string) )
+        empty
+        +> flag "-debug" no_arg ~doc:" Print debugging info into [omake-server-log]"
+        +> anon ("file" %: string) )
       (fun debug file ->
         schedule ~quit:true (fun () ->
           if debug then Omake.debug := true;
 
   let send_to_emacs = Command.basic
     ~summary:"Send a command to emacs."
-    Command.Spec.( flag "-pid" (optional int) ~doc:"PID"
-                   ++ anon ("sexp" %: string) )
+    Command.Spec.( empty
+                   +> flag "-pid" (optional int) ~doc:"PID"
+                   +> anon ("sexp" %: string) )
     (fun pid msg ->
       let pid = Option.map ~f:Pid.of_int pid in
       send (Q.Send_to_emacs (pid, msg)))
 
   let register_emacs = Command.basic
     ~summary:"Register an emacs process."
-    Command.Spec.( anon ("pid" %: int) )
+    Command.Spec.( empty +> anon ("pid" %: int) )
     (fun pid ->
       let pid = Pid.of_int pid in
       send (Q.Register_emacs pid))
 
   let unregister_emacs = Command.basic
     ~summary:"Unregister an emacs process."
-    Command.Spec.( anon ("pid" %: int) )
+    Command.Spec.( empty +> anon ("pid" %: int) )
     (fun pid ->
       let pid = Pid.of_int pid in
       send (Q.Unregister_emacs pid))
 
   let watch = Command.basic
     ~summary:"Watch a project"
-    Command.Spec.( anon ("pid" %: int) ++ anon ("id" %: string) )
+    Command.Spec.( empty +> anon ("pid" %: int) +> anon ("id" %: string) )
     (fun pid id ->
       let pid = Pid.of_int pid  in
       let id = Id.of_string id in
 
   let unwatch = Command.basic
     ~summary:"Stop watching a project"
-    Command.Spec.( anon ("pid" %: int) ++ anon ("id" %: string) )
+    Command.Spec.( empty +> anon ("pid" %: int) +> anon ("id" %: string) )
     (fun pid id ->
       let pid = Pid.of_int pid  in
       let id = Id.of_string id in
 
   let list_watched = Command.basic
     ~summary:"List watched projects"
-    Command.Spec.( anon ("pid" %: int) )
+    Command.Spec.( empty +> anon ("pid" %: int) )
     (fun pid ->
       let pid = Pid.of_int pid in
       send (Q.List_watched pid))
 
   let create_project = Command.basic
     ~summary:"Create a project"
-    Command.Spec.( flag "-id" (required string) ~doc:"ID"
-                   ++ flag "-omakeroot-dir" (required string) ~doc:"DIR"
-                   ++ flag "-compilation-dir" (optional string) ~doc:"DIR"
-                   ++ flag "-user-command" (optional string) ~doc:"STRING")
+    Command.Spec.( empty
+                   +> flag "-id" (required string) ~doc:"ID"
+                   +> flag "-omakeroot-dir" (required string) ~doc:"DIR"
+                   +> flag "-compilation-dir" (optional string) ~doc:"DIR"
+                   +> flag "-user-command" (optional string) ~doc:"STRING")
     (fun id omakeroot_dir compilation_dir user_command ->
       let id = Id.of_string id in
       let compilation_dir = Option.value ~default:omakeroot_dir compilation_dir in
 
   let kill_project = Command.basic
     ~summary:"Kill a project"
-    Command.Spec.( anon ("id" %: string) )
+    Command.Spec.( empty +> anon ("id" %: string) )
     (fun id -> send (Q.Kill_project (`Id (Id.of_string id))))
 
   let list_projects = Command.basic
     ~summary:"List projects"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.List_projects_emacs)
 
   let update_projects = Command.basic
     ~summary:"Update projects"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Update_projects)
 
   let get_project_env = Command.basic
     ~summary:"Get a project environment variable."
-    Command.Spec.( anon ("id" %: string) ++ anon ("var" %: string) )
+    Command.Spec.( empty +> anon ("id" %: string) +> anon ("var" %: string) )
     (fun id var ->
       let id = Id.of_string id in
       let var = Env.var_of_string var in
 
   let set_project_env = Command.basic
     ~summary:"Set a project environment variable."
-    Command.Spec.( anon ("id" %: string)
-                   ++ anon ("var" %: string)
-                   ++ anon ("value" %: bool) )
+    Command.Spec.( empty
+                   +> anon ("id" %: string)
+                   +> anon ("var" %: string)
+                   +> anon ("value" %: bool) )
     (fun id var v ->
       let id = Id.of_string id in
       let var = Env.var_of_string var in
 
   let list = Command.basic
     ~summary:"List projects"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.List_projects)
 
   let kill = Command.basic
     ~summary:"Kill a project"
-    Command.Spec.( anon (maybe ("id|index" %: string)) )
+    Command.Spec.( empty +> anon (maybe ("id|index" %: string)) )
     (fun arg ->
       let arg = match arg with
       | None -> Sys.getcwd ()
 
   let create = Command.basic
     ~summary:"Create a project"
-    Command.Spec.( anon (maybe ("dir" %: string))
-                   ++ flag "-user-command" (optional string) ~doc:"STRING")
+    Command.Spec.( empty
+                   +> anon (maybe ("dir" %: string))
+                   +> flag "-user-command" (optional string) ~doc:"STRING")
     (fun dir cmd ->
       let dir = match dir with
       | None -> Sys.getcwd ()
 
   let kill_when_unwatched = Command.basic
     ~summary:"kill a project when unwatched?"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Kill_when_unwatched)
 
   let omake_command = Command.basic
     ~summary:"default omake command"
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Omake_command)
 
   let warn_when_setting_env_vars = Command.basic
     ~summary:"warn that env changes only take effect on the next build."
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Warn_when_setting_env_vars)
 
   let don't_warn_when_setting_env_vars = Command.basic
     ~summary:"Never warn about env changes again."
-    Command.Spec.( const () )
+    Command.Spec.( empty +> const () )
     (fun () -> send Q.Don't_warn_when_setting_env_vars)
 
 end