Commits

Peter Szilagyi committed 7df0857

Don't write default server config files, either.
Only write config files on changes.

Comments (0)

Files changed (3)

 
 changes
 =======
-- Don't save defaults in omake-server project envs, only user settings.
+- Don't save defaults in omake-server configurations, only user
+  settings.  This is mainly for forward-compatibility, to avoid saving
+  old defaults which later need to be changed.  (In progress.)
 - Minor ocp-indent updates to track the OCamlPro GitHub repo.
 
 ================================================================================

elisp/omake/omake-project.el

   (assert (Omake.Id.is id))
   (List.find (lambda (p) (equal (Omake.Project.id p) id)) Omake.Project.list))
 ;; (Omake.Project.find (Omake.Id.of-path "/home/seanmcl/ocaml/ocaml1"))
+;; (Omake.Project.find (Omake.Id.of-path "/home/pszilagyi/local/jane-elisp/test"))
 
 (defun Omake.Project.current ()
   (Omake.Model.project (Omake.Model.current)))

ocaml/omake/server_config.ml

 
 let t = ref default
 
-let getenv_exn key = match Sys.getenv key with
-  | None -> failwithf "No env: %s" key ()
-  | Some data -> data
-
-let home = getenv_exn "HOME"
+let home = Sys.getenv_exn "HOME"
 
 let config_dir = sprintf "%s/.omake-server" home
 
 
 let has_config_file () = Sys.file_exists_exn config_file
 
-let write_default_file () =
-  if not (has_config_file ()) then
-    Config.write_file config_file default
-
 let init () =
-  begin
-    (* This also serves to create the config dir that other code expects to exist: *)
-    Shell.mkdir ~p:() config_dir;
-    write_default_file ();
+  if has_config_file () then
     match Config.read_file config_file with
     | Ok c ->
       t := c
     | Error exn ->
       Log.printf "Can't read server config file (%s)." config_file;
-      Log.printf "  (%s)" (Exn.to_string exn);
-      t := default
-  end
+      Log.printf "  (%s)" (Exn.to_string exn)
 
 let _ = init ()
 
 let don't_warn_when_setting_env_vars () =
   begin
     Config.update (!t) ~key:"warn_when_setting_env_vars" ~value:"false";
+    Shell.mkdir ~p:() config_dir;
     Config.write_file config_file (!t)
   end