Parcourir la source

Auto-indent source files

 - Indented running ./fix-indent.ml src.
 - Avoid indentation of Atdgen generated files.
 - Some comments where change as follow to keep the list information.
This
(* TODO:
  * Element 1
  * Element 2
  * Element 3
  * Element 4
becomes
(* TODO:
 * Element 1
 * Element 2
 * Element 3
 * Element 4
So to keep a list appearance, I add - like this
(* TODO:
 * - Element 1
 * - Element 2
 * - Element 3
 * - Element 4
Leo il y a 9 ans
Parent
commit
2d730795f6
22 fichiers modifiés avec 588 ajouts et 588 suppressions
  1. 13 13
      src/add_command.ml
  2. 105 105
      src/command_def.ml
  3. 17 17
      src/const.ml
  4. 9 9
      src/default.ml
  5. 61 61
      src/edit_command.ml
  6. 30 30
      src/exec_cmd.ml
  7. 15 15
      src/file_com.ml
  8. 23 23
      src/licencing.ml
  9. 17 17
      src/list_rc.ml
  10. 18 18
      src/lock.ml
  11. 67 67
      src/messages.ml
  12. 25 25
      src/remove_command.ml
  13. 11 11
      src/signals.ml
  14. 15 15
      src/state.ml
  15. 11 11
      src/test/ec_t.ml
  16. 19 19
      src/test/edit_t.ml
  17. 23 23
      src/test/exec_t.ml
  18. 2 2
      src/test/test.ml
  19. 16 16
      src/test/unify_t.ml
  20. 59 59
      src/tmp_file.ml
  21. 11 11
      src/tools.ml
  22. 21 21
      src/unify.ml

+ 13 - 13
src/add_command.ml

@@ -40,15 +40,15 @@ open Core.Std;;
 
 (* Function to create a new list augmented by some commands *)
 let new_list current_list position new_items =
-    match position with
-    | None -> List.append current_list new_items
-    | Some n -> (* If a number is given, add commands after position n by
-    splitting the list and concatenating all. List.split_n works like this :
-        * #let l1 = [1;2;3;4;5;6] in
-        * # List.split_n l1 2;;
-        * - : int list * int list = ([1; 2], [3; 4; 5; 6]) *)
+  match position with
+  | None -> List.append current_list new_items
+  | Some n -> (* If a number is given, add commands after position n by
+                 splitting the list and concatenating all. List.split_n works like this :
+               * #let l1 = [1;2;3;4;5;6] in
+               * # List.split_n l1 2;;
+               * - : int list * int list = ([1; 2], [3; 4; 5; 6]) *)
     let l_begin,l_end = List.split_n current_list n in
-    List.concat [ l_begin ; new_items ; l_end ]
+      List.concat [ l_begin ; new_items ; l_end ]
 ;;
 
 
@@ -56,13 +56,13 @@ let new_list current_list position new_items =
 (* Function which add the commands (one per line) ridden on stdin to the rc
  * file, and then display th new configuration *)
 let run ~(rc:File_com.t) position =
-    (* Read command from stdin, as a list. fix_win_eol removes \r\n *)
-    let cmd_list = In_channel.input_lines ~fix_win_eol:true In_channel.stdin in
-    (* Create an updated rc file *)
-    let updated_rc = { rc with Settings_t.progs = (new_list rc.Settings_t.progs position cmd_list)} in
+  (* Read command from stdin, as a list. fix_win_eol removes \r\n *)
+  let cmd_list = In_channel.input_lines ~fix_win_eol:true In_channel.stdin in
+  (* Create an updated rc file *)
+  let updated_rc = { rc with Settings_t.progs = (new_list rc.Settings_t.progs position cmd_list)} in
     File_com.write updated_rc;
     (* Display the result *)
     let reread_rc = File_com.init_rc () in
-    List_rc.run ~rc:reread_rc ()
+      List_rc.run ~rc:reread_rc ()
 ;;
 

+ 105 - 105
src/command_def.ml

@@ -48,46 +48,46 @@ type return_arg = {
 (* A set of default arguments, usable with most of the commands *)
 let shared_params =
   let open Param in
-  (* Way to treat common args *)
-  return (fun verbosity no_color rc_file_name handle_signal ->
-    (* Set the level of verbosity *)
-    Const.verbosity := verbosity;
-    (* Do not use color *)
-    Const.no_color := no_color;
-    (* Use given rc file, should run the nth argument if present *)
-    Const.rc_file := (Lazy.return rc_file_name);
-    (* Active signal handling *)
-    if handle_signal then
-      Signals.handle ();
+    (* Way to treat common args *)
+    return (fun verbosity no_color rc_file_name handle_signal ->
+       (* Set the level of verbosity *)
+       Const.verbosity := verbosity;
+       (* Do not use color *)
+       Const.no_color := no_color;
+       (* Use given rc file, should run the nth argument if present *)
+       Const.rc_file := (Lazy.return rc_file_name);
+       (* Active signal handling *)
+       if handle_signal then
+         Signals.handle ();
 
-    (* Debugging *)
-    Messages.debug (sprintf "Verbosity set to %i" !Const.verbosity);
-    Messages.debug (sprintf "Color %s" (match !Const.no_color with true -> "off" | false -> "on"));
-    Messages.debug (sprintf "Configuration file is %s" (Lazy.force !Const.rc_file));
-    Messages.debug (sprintf "Tmp file is %s" Const.tmp_file);
+       (* Debugging *)
+       Messages.debug (sprintf "Verbosity set to %i" !Const.verbosity);
+       Messages.debug (sprintf "Color %s" (match !Const.no_color with true -> "off" | false -> "on"));
+       Messages.debug (sprintf "Configuration file is %s" (Lazy.force !Const.rc_file));
+       Messages.debug (sprintf "Tmp file is %s" Const.tmp_file);
 
-    (* Obtain data from rc_file *)
-    let rc_content = File_com.init_rc () in
-    { rc = rc_content } (* We use type for futur use *)
-  )
-  (* Flag to set verbosity level *)
+       (* Obtain data from rc_file *)
+       let rc_content = File_com.init_rc () in
+         { rc = rc_content } (* We use type for futur use *)
+     )
+    (* Flag to set verbosity level *)
     <*> flag "-v" (optional_with_default !Const.verbosity int)
-      ~aliases:["--verbose" ; "-verbose"]
-      ~doc:"[n] Set verbosity level. \
-        The higher n is, the most verbose the program is."
+          ~aliases:["--verbose" ; "-verbose"]
+          ~doc:"[n] Set verbosity level. \
+                The higher n is, the most verbose the program is."
     (* Flag to set colors *)
     <*> flag "--no-color" no_arg
-        ~aliases:["-no-color"]
-        ~doc:" Use this flag to disable color usage."
+          ~aliases:["-no-color"]
+          ~doc:" Use this flag to disable color usage."
     (* Flag to use different rc file *)
     <*> flag "-c" (optional_with_default (Lazy.force !Const.rc_file) file)
-      ~aliases:["--rc" ; "-rc"]
-      ~doc:"file Read configuration from the given file and continue parsing."
+          ~aliases:["--rc" ; "-rc"]
+          ~doc:"file Read configuration from the given file and continue parsing."
     (* Flag to handle signals *)
     <*> flag "-s" no_arg
-      ~aliases:["--sinals" ; "-signals"]
-      ~doc:"Handle signals. Warning, this is not much tested and not \
-      implemented the best way."
+          ~aliases:["--sinals" ; "-signals"]
+          ~doc:"Handle signals. Warning, this is not much tested and not \
+                implemented the best way."
 ;;
 
 
@@ -97,25 +97,25 @@ let shared_params =
 let reset =
   basic
     ~summary:"Reinitialises launches for the command number [command] to [n]. \
-      With both the [command] and the [n] argumennt, the command number \
-      [command] is resetted to [n]. \
-      With only the [n] argument, every entry in current tmp file is resetted to [n]."
+              With both the [command] and the [n] argumennt, the command number \
+              [command] is resetted to [n]. \
+              With only the [n] argument, every entry in current tmp file is resetted to [n]."
     Spec.(
       empty
-       +> shared_params
-       +> anon ("target_number" %: int)
-       +> anon (maybe ("command_number" %: int))
+      +> shared_params
+      +> anon ("target_number" %: int)
+      +> anon (maybe ("command_number" %: int))
     )
     (fun { rc } num cmd () ->
-      (* Call the right function, according to optionnal argument.
-       * Since it's arguments passed on command line, we can not have
-       * num = None
-       * cmd = Some n
-       * cmd: number of the command to be reseted
-       * num: number to reset *)
-        match ( num, cmd ) with
-        | ( num, Some cmd ) -> Tmp_file.reset_cmd ~rc num cmd
-        | ( num, None ) -> Tmp_file.reset2num ~rc num
+       (* Call the right function, according to optionnal argument.
+        * Since it's arguments passed on command line, we can not have
+        * num = None
+        * cmd = Some n
+        * cmd: number of the command to be reseted
+        * num: number to reset *)
+       match ( num, cmd ) with
+       | ( num, Some cmd ) -> Tmp_file.reset_cmd ~rc num cmd
+       | ( num, None ) -> Tmp_file.reset2num ~rc num
     )
 ;;
 let reset_all =
@@ -123,10 +123,10 @@ let reset_all =
     ~summary:" Reinitialises launches for everything."
     Spec.(
       empty
-       +> shared_params
+      +> shared_params
     )
     (fun { rc } () ->
-      Tmp_file.reset_all ()
+       Tmp_file.reset_all ()
     )
 ;;
 
@@ -134,26 +134,26 @@ let reset_all =
 let list =
   basic
     ~summary:"Print a list of all commands with their number. Useful to launch with number. \
-    Displays a star next to next command to launch."
+              Displays a star next to next command to launch."
     Spec.(
       empty
       +> shared_params
     )
     (fun { rc } () ->
-      List_rc.run ~rc ())
+       List_rc.run ~rc ())
 ;;
 
 (* To clean-up rc file *)
 let clean =
   basic
     ~summary:"Remove doubled entries, trailing spaces in them... \
-    Useful after manual editing or with rc file from old version."
+              Useful after manual editing or with rc file from old version."
     Spec.(
       empty
       +> shared_params
     )
     (fun { rc } () ->
-      Clean_command.run ~rc ()
+       Clean_command.run ~rc ()
     )
 ;;
 
@@ -161,14 +161,14 @@ let clean =
 let add =
   basic
     ~summary:"Add the command given on stdin to the configuration file at a \
-    given position ([NUMBER]). If nothing is given, append it."
+              given position ([NUMBER]). If nothing is given, append it."
     Spec.(
       empty
       +> shared_params
       +> anon  (maybe ("number" %: int))
     )
     (fun { rc } num_cmd () ->
-      Add_command.run ~rc num_cmd
+       Add_command.run ~rc num_cmd
     )
 ;;
 
@@ -176,15 +176,15 @@ let add =
 let delete =
   basic
     ~summary:"Remove the [COMMAND_NUMBER]th command from configuration file. \
-    If [COMMAND_NUMBER] is absent, remove last one."
+              If [COMMAND_NUMBER] is absent, remove last one."
     Spec.(
       empty
-       +> shared_params
-       +> anon (maybe ("command_number" %: int))
+      +> shared_params
+      +> anon (maybe ("command_number" %: int))
     )
     (fun { rc } num_cmd () ->
-      (*Tmp_file.reset ~rc reset_cmd 0)*)
-      Remove_command.run ~rc num_cmd)
+       (*Tmp_file.reset ~rc reset_cmd 0)*)
+       Remove_command.run ~rc num_cmd)
 ;;
 
 (* To display current state *)
@@ -196,7 +196,7 @@ let state =
       +> shared_params
     )
     (fun { rc } () ->
-      State.print_current ~rc ())
+       State.print_current ~rc ())
 ;;
 
 
@@ -204,18 +204,18 @@ let state =
 let edit =
   basic
     ~summary:"Edit the [COMMAND_NUMBER]th command of the rc file in your \
-    $EDITOR. May be used to add new entries, without argument, one new \
-    command per line."
+              $EDITOR. May be used to add new entries, without argument, one new \
+              command per line."
     Spec.(
       empty
       +> shared_params
       +> anon (maybe ("command_number" %: int))
     )
     (fun { rc } n () ->
-      let position = Option.value
-        ~default:(List.length (rc.Settings_t.progs) - 1) n
-      in
-      Edit_command.run ~rc position)
+       let position = Option.value
+                        ~default:(List.length (rc.Settings_t.progs) - 1) n
+       in
+         Edit_command.run ~rc position)
 ;;
 
 (* To display informations about the licence *)
@@ -224,13 +224,13 @@ let licence =
     ~summary:"Display the licence of the program"
     Spec.(
       empty
-       +> shared_params
-       +> flag "-header" no_arg
-        ~doc:" Display the header of the licence"
+      +> shared_params
+      +> flag "-header" no_arg
+           ~doc:" Display the header of the licence"
     )
     (fun _ header () ->
-      let cecill = not(header) in (* When cecill is false, it displays the header *)
-      Licencing.print ~cecill
+       let cecill = not(header) in (* When cecill is false, it displays the header *)
+         Licencing.print ~cecill
     )
 ;;
 
@@ -244,7 +244,7 @@ let default =
       +> anon (maybe ("command_number" %: int))
     )
     (fun { rc } n () ->
-      Default.run ~rc n)
+       Default.run ~rc n)
 
 let run ~version ~build_info () =
   (* Store begin time *)
@@ -258,26 +258,26 @@ let run ~version ~build_info () =
       default
       |> run ~version ~build_info
     in
-    match Sys.argv with
-    | [| _ |] -> Result.Ok (run_default ()) (* Program called with nothing *)
-    | _ -> (* Program followed by a number *)
+      match Sys.argv with
+      | [| _ |] -> Result.Ok (run_default ()) (* Program called with nothing *)
+      | _ -> (* Program followed by a number *)
         Or_error.try_with (fun () ->
-          (* Verify the fist argument is a number, not a subcommand (string) *)
-          ignore (Int.of_string (Sys.argv.(1)));
-          run_default ())
+           (* Verify the fist argument is a number, not a subcommand (string) *)
+           ignore (Int.of_string (Sys.argv.(1)));
+           run_default ())
   in
 
   (* Parsing with subcommands *)
   let parse_sub () =
     group
       ~summary:"OcLaunch program is published under CeCILL licence.\n \
-      You may run the program with 'licence' command or see \
-      http://cecill.info/licences/Licence_CeCILL_V2.1-en.html \
-      (http://huit.re/TmdOFmQT) for details. More informations here: \
-      http://oclaunch.eu.org/floss-under-cecill (http://lnch.ml/l)."
+                You may run the program with 'licence' command or see \
+                http://cecill.info/licences/Licence_CeCILL_V2.1-en.html \
+                (http://huit.re/TmdOFmQT) for details. More informations here: \
+                http://oclaunch.eu.org/floss-under-cecill (http://lnch.ml/l)."
       ~readme:(fun () -> "Use 'help' subcommand to get help (it works both \
-      after the name of the software and with another subcommand). For \
-      further help, see http://oclaunch.eu.org.")
+                          after the name of the software and with another subcommand). For \
+                          further help, see http://oclaunch.eu.org.")
       ~preserve_subcommand_order:()
       [ ("run", default) ; ("licence", licence) ; ("add", add) ; ("edit", edit)
       ; ("list", list) ; ("cleanup", clean) ; ("delete", delete)
@@ -290,33 +290,33 @@ let run ~version ~build_info () =
     match
       hack_parse ()
       |> (function
-        Result.Ok () -> ()
-        | Error _ -> parse_sub ())
+           Result.Ok () -> ()
+         | Error _ -> parse_sub ())
     with
     | () -> `Exit 0
     | exception message ->
-        "Exception: " ^ (Exn.to_string message)
-        |> Messages.warning;
-        `Exit 20
+      "Exception: " ^ (Exn.to_string message)
+      |> Messages.warning;
+      `Exit 20
   in
 
-  (* Unlock, should be done before *)
-  Lock.(status ()
-    |> (function
-        Locked ->
-          Messages.warning "Removing lockfile, should be removed before. \
-          It's a bug!"; remove ()
-      | Free -> ()
-      | Error -> Messages.warning "Error with lockfile"
-  ));
+    (* Unlock, should be done before *)
+    Lock.(status ()
+          |> (function
+               Locked ->
+               Messages.warning "Removing lockfile, should be removed before. \
+                                 It's a bug!"; remove ()
+             | Free -> ()
+             | Error -> Messages.warning "Error with lockfile"
+           ));
 
-  (* Display total running time, pretty printing is handled by Time module *)
-  Messages.debug Time.(diff (now ()) start
-      |> Span.to_string_hum (* Round the value, 3 digits *)
-      |> sprintf "Duration: %s");
+    (* Display total running time, pretty printing is handled by Time module *)
+    Messages.debug Time.(diff (now ()) start
+                         |> Span.to_string_hum (* Round the value, 3 digits *)
+                         |> sprintf "Duration: %s");
 
-  (* Reset display *)
-  Messages.reset ();
+    (* Reset display *)
+    Messages.reset ();
 
-  exit_code
+    exit_code
 ;;

+ 17 - 17
src/const.ml

@@ -41,33 +41,33 @@ open Core.Std;;
 (* General function to get environment variables
  * exp: exception*)
 let get_var ?(exp=false) ?default name =
-    let msg =
-        lazy (sprintf "ERROR: Couldn't get %s. Please consider setting it." name)
-    in
-    (* Return value or exception *)
-    let run_exn () =
-        match exp with
-        | true -> failwith (Lazy.force msg)
-        | false -> print_endline (Lazy.force msg); ""
-    in
+  let msg =
+    lazy (sprintf "ERROR: Couldn't get %s. Please consider setting it." name)
+  in
+  (* Return value or exception *)
+  let run_exn () =
+    match exp with
+    | true -> failwith (Lazy.force msg)
+    | false -> print_endline (Lazy.force msg); ""
+  in
     (* Get the var *)
     Sys.getenv name
     |> (function
-        | Some x -> x
-        | None ->
-                match default with
-                | None -> run_exn ()
-                | Some default -> default)
+       | Some x -> x
+       | None ->
+         match default with
+         | None -> run_exn ()
+         | Some default -> default)
 ;;
 
 (* Get current home *)
 let home =
-    lazy (get_var ~exp:true "HOME")
+  lazy (get_var ~exp:true "HOME")
 ;;
 
 (* Get default editor *)
 let editor = (* If editor is not set, it gets "", but an exception is raised *)
-    lazy (get_var ~exp:true "EDITOR")
+  lazy (get_var ~exp:true "EDITOR")
 ;;
 
 (* Level of verbosity, used by Messages module *)
@@ -77,7 +77,7 @@ let no_color = ref false;;
 
 (* Default place to read settings *)
 let rc_file_default = Lazy.(home >>| (fun home -> home ^ "/" ^
-    ".oclaunch_rc.json"));;
+                                                  ".oclaunch_rc.json"));;
 (* Current place to read settings, maybe modified from command line argument *)
 let rc_file = ref rc_file_default;;
 (* Set tmp file, in witch stock launches, in biniou format *)

+ 9 - 9
src/default.ml

@@ -50,21 +50,21 @@ let run ~rc cmd_number =
   Messages.debug "Locked";
 
   let tmp = Tmp_file.init () in
-  match cmd_number with
+    match cmd_number with
     | None -> begin
         (* Execute each item (one by one) in config file *)
         Exec_cmd.what_next ~tmp
-          |> function
-            | None -> (* If no command was found, all has been launched *)
-                Messages.ok "All has been launched!";
-                Messages.tips "You can reset with 'reset' subcommand";
-                Lock.remove ()
-            | Some cmd_to_exec -> Exec_cmd.execute cmd_to_exec;
+        |> function
+        | None -> (* If no command was found, all has been launched *)
+          Messages.ok "All has been launched!";
+          Messages.tips "You can reset with 'reset' subcommand";
+          Lock.remove ()
+        | Some cmd_to_exec -> Exec_cmd.execute cmd_to_exec;
       end
     | Some num -> begin
         File_com.num_cmd2cmd ~rc num
         |> function
-            | None -> Messages.warning "Your number is out of bound"
-            | Some cmd_to_exec -> Exec_cmd.execute cmd_to_exec;
+        | None -> Messages.warning "Your number is out of bound"
+        | Some cmd_to_exec -> Exec_cmd.execute cmd_to_exec;
       end
 ;;

+ 61 - 61
src/edit_command.ml

@@ -46,86 +46,86 @@ let epur =
 (* Function to create a new list augmented by some commands *)
 (* TODO Factorise this *)
 let new_list current_list position new_items =
-    (* If a number is given, add commands after position n by
-    splitting the list and concatenating all. List.split_n works like this :
-        * #let l1 = [1;2;3;4;5;6] in
-        * # List.split_n l1 2;;
-        * - : int list * int list = ([1; 2], [3; 4; 5; 6]) *)
-    let l_begin,l_end = List.split_n current_list position in
+  (* If a number is given, add commands after position n by
+     splitting the list and concatenating all. List.split_n works like this :
+   * #let l1 = [1;2;3;4;5;6] in
+   * # List.split_n l1 2;;
+   * - : int list * int list = ([1; 2], [3; 4; 5; 6]) *)
+  let l_begin,l_end = List.split_n current_list position in
     List.concat [ l_begin ; new_items ; l_end ]
 ;;
 
 
 (* Concat edited item, to have a proper list to display
-    * If only one element, return "elt".
-    * If more than one "\nelt1\nelt2\nelt3\n" *)
+ * If only one element, return "elt".
+ * If more than one "\nelt1\nelt2\nelt3\n" *)
 let gen_modification items =
-    let r = "\n" in
+  let r = "\n" in
     epur items
     |> (function
-        | [] -> ""
-        (* Only one element *)
-        | element :: [] -> element
-        (* The list as more than two elements *)
-        | items ->
-                let msg = String.concat ~sep:r items in
-                String.concat [ r ; msg ; r ])
+       | [] -> ""
+       (* Only one element *)
+       | element :: [] -> element
+       (* The list as more than two elements *)
+       | items ->
+         let msg = String.concat ~sep:r items in
+           String.concat [ r ; msg ; r ])
 ;;
 
 (* Function which get the nth element, put it in a file, let the user edit it,
  * and then remplace with the new result *)
 let rec run ~(rc:File_com.t) position =
-    (* Current list of commands *)
-    let current_list = rc.Settings_t.progs in
+  (* Current list of commands *)
+  let current_list = rc.Settings_t.progs in
 
-    (* Creating tmp file, for editing *)
-    let tmp_filename = [
-        "/tmp/oc_edit_" ;
-        (Int.to_string (Random.int 100_000)) ;
-        ".txt" ;
-    ] in
-    let tmp_edit = String.concat tmp_filename in
-    (* Remove item to be edited *)
-    let original_command,shorter_list =
-      Remove_command.remove current_list position
-    in
+  (* Creating tmp file, for editing *)
+  let tmp_filename = [
+    "/tmp/oc_edit_" ;
+    (Int.to_string (Random.int 100_000)) ;
+    ".txt" ;
+  ] in
+  let tmp_edit = String.concat tmp_filename in
+  (* Remove item to be edited *)
+  let original_command,shorter_list =
+    Remove_command.remove current_list position
+  in
     Out_channel.write_all tmp_edit original_command;
 
 
     (* Edit file *)
     let edit = String.concat [ Lazy.force Const.editor ; " " ; tmp_edit ] in
-    Messages.debug edit;
-    Sys.command edit
-    |> (function
-        0 -> ()
-        | n -> sprintf "Error while running %s: error code %i" edit n
-        |> Messages.warning);
+      Messages.debug edit;
+      Sys.command edit
+      |> (function
+           0 -> ()
+         | n -> sprintf "Error while running %s: error code %i" edit n
+                |> Messages.warning);
 
-    (* Reading and applying the result *)
-    let new_commands = In_channel.read_lines tmp_edit |> epur in
-    let cmd_list = new_list shorter_list position new_commands in
-    let updated_rc = { rc with Settings_t.progs = cmd_list} in
-    File_com.write updated_rc;
-    (* Display the result, only if modified *)
-    let new_cmd_mod = gen_modification new_commands in
-    (* We are doing things in this order to avoid multiple listing of rc file
-     * when reediting. *)
-    if ( original_command = new_cmd_mod )
-    then (* Nothing change, try reediting *)
-      begin
-        let open Messages in
-        warning "Nothing changed.";
-        confirm "Do you want to reedit?"
-        |> function
-          | Yes -> run ~rc position
-          | No -> ()
-      end
+      (* Reading and applying the result *)
+      let new_commands = In_channel.read_lines tmp_edit |> epur in
+      let cmd_list = new_list shorter_list position new_commands in
+      let updated_rc = { rc with Settings_t.progs = cmd_list} in
+        File_com.write updated_rc;
+        (* Display the result, only if modified *)
+        let new_cmd_mod = gen_modification new_commands in
+          (* We are doing things in this order to avoid multiple listing of rc file
+           * when reediting. *)
+          if ( original_command = new_cmd_mod )
+          then (* Nothing change, try reediting *)
+            begin
+              let open Messages in
+                warning "Nothing changed.";
+                confirm "Do you want to reedit?"
+                |> function
+                | Yes -> run ~rc position
+                | No -> ()
+            end
 
-    else (* Display summary of changes *)
-      begin
-        sprintf "'%s' -> '%s'\n" original_command new_cmd_mod |> Messages.ok;
-        (* Display new rc file *)
-        let reread_rc = File_com.init_rc () in
-        List_rc.run ~rc:reread_rc ()
-      end;
+          else (* Display summary of changes *)
+            begin
+              sprintf "'%s' -> '%s'\n" original_command new_cmd_mod |> Messages.ok;
+              (* Display new rc file *)
+              let reread_rc = File_com.init_rc () in
+                List_rc.run ~rc:reread_rc ()
+            end;
 ;;

+ 30 - 30
src/exec_cmd.ml

@@ -39,10 +39,10 @@ open Core.Std;;
 (* Function allowing to set the title of the current terminal windows
  * XXX Maybe better in some lib *)
 let set_title new_title =
-    (* Use echo command to set term  title *)
-    Sys.command (sprintf "echo -en \"\\033]0;%s\\a\"" new_title)
-    |> function | 0 -> () | _ -> sprintf "Error while setting terminal title"
-    |> Messages.warning
+  (* Use echo command to set term  title *)
+  Sys.command (sprintf "echo -en \"\\033]0;%s\\a\"" new_title)
+  |> function | 0 -> () | _ -> sprintf "Error while setting terminal title"
+                               |> Messages.warning
 ;;
 
 (* Function to return the less launched command, at least the first one *)
@@ -53,10 +53,10 @@ let less_launched (log : (string * int) list) =
   let entries_by_number = List.Assoc.inverse log  in
     List.min_elt ~cmp:(fun (n,_) (n',_) -> Int.compare n n') entries_by_number
     |> (function Some (min,cmd) ->
-        if min < max
-        then Some cmd
-        else None
-      | None -> None)
+       if min < max
+       then Some cmd
+       else None
+               | None -> None)
 ;;
 
 (* Function to get the number corresponding to the next command to launch (less
@@ -69,20 +69,20 @@ let less_launched_num log =
   (* Function to return nothing (None) when max launch number is reached, Some
    * number otherwise *)
   |> List.filter_mapi ~f:(fun entry_number ( _, launch_number ) ->
-      if launch_number >= Const.default_launch
-      then None
-      else Some ( entry_number, launch_number ))
+     if launch_number >= Const.default_launch
+     then None
+     else Some ( entry_number, launch_number ))
   (* Find the less launched by sorting and taking the first *)
   |> List.sort ~cmp:(fun ( _, launch_number1 ) ( _, launch_number2 ) -> Int.compare launch_number1 launch_number2)
   |> List.hd
   |> function
-    | Some ( entry_number, launch_number) ->
-        launch_number |> sprintf "Launch number found: %i" |> Messages.debug;
-        Messages.debug "Return launch number (printed bellow):";
-        Some ( Tools.spy1_int entry_number )
-    | None ->
-        Messages.debug "No less launched cmd.";
-        None
+  | Some ( entry_number, launch_number) ->
+    launch_number |> sprintf "Launch number found: %i" |> Messages.debug;
+    Messages.debug "Return launch number (printed bellow):";
+    Some ( Tools.spy1_int entry_number )
+  | None ->
+    Messages.debug "No less launched cmd.";
+    None
 ;;
 
 (* Function to determinate what is the next command to
@@ -97,11 +97,11 @@ let what_next ~tmp =
  * if 0 status, do nothing
  * else display status number *)
 let display_result command status =
-    match status with
-    | 0 -> (* No problem, do nothing *) ()
-    | _ -> (* Problem occur,  display it *)
-            sprintf "Problem while running: '%s'\nExited with code: %i\n"
-            command status
+  match status with
+  | 0 -> (* No problem, do nothing *) ()
+  | _ -> (* Problem occur,  display it *)
+    sprintf "Problem while running: '%s'\nExited with code: %i\n"
+      command status
     |> Messages.warning
 ;;
 
@@ -109,11 +109,11 @@ let display_result command status =
 let execute ?(display=true) cmd =
   set_title cmd;
 
-    Tmp_file.log ~cmd ~func:((+) 1) ();
-    if display then
-        Messages.ok cmd;
-    (* We can remove lock file since number in tmp_file has been incremented *)
-    Lock.remove ();
-    Sys.command cmd
-    |> display_result cmd (* Make it settable in rc file *)
+  Tmp_file.log ~cmd ~func:((+) 1) ();
+  if display then
+    Messages.ok cmd;
+  (* We can remove lock file since number in tmp_file has been incremented *)
+  Lock.remove ();
+  Sys.command cmd
+  |> display_result cmd (* Make it settable in rc file *)
 ;;

+ 15 - 15
src/file_com.ml

@@ -43,13 +43,13 @@ type t = Settings_v.rc_file;;
 
 (* Function to write the rc file *)
 let write (rc_file:t) =
-        (* Short name *)
-        let name = !Const.rc_file in
-        (* Create string to be written, after removing duplicated commands (and
-         * newlines) *)
-        let data = (Unify.prettify rc_file |> Settings_j.string_of_rc_file
-        |> Yojson.Basic.prettify ~std:true) in
-        Out_channel.write_all (Lazy.force name) ~data
+  (* Short name *)
+  let name = !Const.rc_file in
+  (* Create string to be written, after removing duplicated commands (and
+   * newlines) *)
+  let data = (Unify.prettify rc_file |> Settings_j.string_of_rc_file
+              |> Yojson.Basic.prettify ~std:true) in
+    Out_channel.write_all (Lazy.force name) ~data
 ;;
 
 (* Return the configuration file template *)
@@ -76,17 +76,17 @@ let create_rc_file ~name =
 
 (* Function to read the rc file *)
 let rec init_rc ?(rc=(!Const.rc_file)) () =
-   let rc' = Lazy.force rc in
-  (* Verify that file exist *)
-  match (Sys.file_exists rc') with
+  let rc' = Lazy.force rc in
+    (* Verify that file exist *)
+    match (Sys.file_exists rc') with
     | `No -> create_rc_file ~name:rc'; init_rc ~rc ();
     | `Unknown -> failwith "Error reading configuration file";
     | `Yes -> (* Try to read, if there is an error, reset file *)
-            try
-                In_channel.read_all rc' |> Settings_j.rc_file_of_string
-            with
-            | Yojson.Json_error _ -> (* Invalid file, delete, so that it will be reseted
-            on next call *) Sys.remove rc'; init_rc ~rc ()
+      try
+        In_channel.read_all rc' |> Settings_j.rc_file_of_string
+      with
+      | Yojson.Json_error _ -> (* Invalid file, delete, so that it will be reseted
+                                  on next call *) Sys.remove rc'; init_rc ~rc ()
 ;;
 
 (* Get the command corresponding to a number *)

+ 23 - 23
src/licencing.ml

@@ -1206,31 +1206,31 @@ let print ~cecill =
 
       (* Spying expression *)
       |> (fun str ->
-          Option.value ~default:"" str |> Messages.debug;
-          str)
+         Option.value ~default:"" str |> Messages.debug;
+         str)
 
       |> (function
-        | Some "en" | Some "En" | Some "EN" -> `En
-        | Some "fr" | Some "Fr" | Some "FR"-> `Fr
-        | None | Some _ -> Messages.warning "Please enter 'Fr' or 'En'"; def_lang ()
-    ))
+         | Some "en" | Some "En" | Some "EN" -> `En
+         | Some "fr" | Some "Fr" | Some "FR"-> `Fr
+         | None | Some _ -> Messages.warning "Please enter 'Fr' or 'En'"; def_lang ()
+       ))
   in
 
-  Messages.info "Choose your language 'Fr' or 'En': ";
-  (* XXX Be sure to show the message *)
-  Out_channel.(flush stdout);
-
-  let ( warn, licence ) =
-    def_lang ()
-        |> function
-          | `En -> ( en_header, en_licence )
-          | `Fr -> ( fr_header, fr_licence )
-  in
-  begin
-    match cecill with
-    | false -> Messages.debug "Choosing warn"; warn
-    | true -> Messages.debug "Choosing licence"; licence
-  end
-    |> print_endline (* XXX Using print_endline to ensure we can't avoid printing
-    with verbosity parameter *)
+    Messages.info "Choose your language 'Fr' or 'En': ";
+    (* XXX Be sure to show the message *)
+    Out_channel.(flush stdout);
+
+    let ( warn, licence ) =
+      def_lang ()
+      |> function
+      | `En -> ( en_header, en_licence )
+      | `Fr -> ( fr_header, fr_licence )
+    in
+      begin
+        match cecill with
+        | false -> Messages.debug "Choosing warn"; warn
+        | true -> Messages.debug "Choosing licence"; licence
+      end
+      |> print_endline (* XXX Using print_endline to ensure we can't avoid printing
+                          with verbosity parameter *)
 ;;

+ 17 - 17
src/list_rc.ml

@@ -42,28 +42,28 @@ open Core.Std;;
  * argument is kept for backward compatibility *)
 (* FIXME Remove ?rc or use it *)
 (* TODO:
-  * Test it, esp. ordering
-  * Allow to set form of the table, multiple rc file, display next to be
-    * launched… *)
+ * - Test it, esp. ordering
+ * - Allow to set form of the table, multiple rc file, display next to be
+ * launched… *)
 let run ?rc () =
   let rc_numbered =
     File_com.init_rc ()
     |> fun rc -> rc.Settings_t.progs
-    |> List.mapi ~f:(fun i item -> ( item, i ))
+                 |> List.mapi ~f:(fun i item -> ( item, i ))
   in
   let tmp : Tmp_file.t = Tmp_file.init () in
-  Tmp_file.get_accurate_log ~tmp ()
-  (* Generate list to feed the table,
-   * XXX assuming all will be in the right order *)
-  |> List.map ~f:(function
-    ( cmd, number ) ->
-      [ (* Number of a command in rc file, command, number of launch *)
-        (List.Assoc.find_exn rc_numbered cmd |> Int.to_string);
-        cmd;
-        (Int.to_string number)
-      ])
-  |> Textutils.Ascii_table.simple_list_table
-    ~display:Textutils.Ascii_table.Display.column_titles
-    [ "Id" ; "Command" ; "Number of launch" ]
+    Tmp_file.get_accurate_log ~tmp ()
+    (* Generate list to feed the table,
+     * XXX assuming all will be in the right order *)
+    |> List.map ~f:(function
+         ( cmd, number ) ->
+         [ (* Number of a command in rc file, command, number of launch *)
+           (List.Assoc.find_exn rc_numbered cmd |> Int.to_string);
+           cmd;
+           (Int.to_string number)
+         ])
+    |> Textutils.Ascii_table.simple_list_table
+         ~display:Textutils.Ascii_table.Display.column_titles
+         [ "Id" ; "Command" ; "Number of launch" ]
 ;;
 

+ 18 - 18
src/lock.ml

@@ -50,21 +50,21 @@ let lock_name = "/tmp/.ocl.lock";;
 
 (* Create lock file *)
 let lock () =
-    try Out_channel.write_all lock_name ~data:"OcLaunch is running and did not finish."
-    with Sys_error msg -> Messages.debug "Couldn't write in lock file."
+  try Out_channel.write_all lock_name ~data:"OcLaunch is running and did not finish."
+  with Sys_error msg -> Messages.debug "Couldn't write in lock file."
 ;;
 
 (* To know if we are locked, return None if there is no locker,  *)
 let status () =
-    match Sys.file_exists lock_name with
-      `Yes -> Locked
-    | `No -> Free
-    | `Unknown -> Error
+  match Sys.file_exists lock_name with
+    `Yes -> Locked
+  | `No -> Free
+  | `Unknown -> Error
 ;;
 
 (* Remove the lock file *)
 let remove () =
-    Sys.remove lock_name
+  Sys.remove lock_name
 ;;
 
 (* Pause the program until lock file is removed, until argument is the second *)
@@ -74,27 +74,27 @@ let wait ?(until=10) ?(delay=1) () =
   let rec wait_loop loop =
     (* Actually wait, returning what has been done (Something or Nothing) *)
     sprintf "Waiting for locker, loop: %i" loop
-      |> Messages.debug;
+    |> Messages.debug;
     match status () with
       Locked ->
-        if loop < until; then (* < because we start from 0 *)
-          begin
-            Unix.sleep delay;
-            wait_loop (succ loop)
-          end
-        else
-          None
+      if loop < until; then (* < because we start from 0 *)
+        begin
+          Unix.sleep delay;
+          wait_loop (succ loop)
+        end
+      else
+        None
     | Free -> Some (lock ())
     | Error -> failwith "Problem with lock file"
   in
-  wait_loop 0
+    wait_loop 0
     |> (function
-       None ->
+         None ->
          Messages.warning "Removing lock file, ran out of patience";
          remove ();
          (* We need to lock back, since it's the purpose of this function *)
          lock ()
        | _ -> ()
-    )
+     )
 ;;
 

+ 67 - 67
src/messages.ml

@@ -39,7 +39,7 @@ open Core.Std;;
 (* Modules to manage output messages, with color *)
 
 (* TODO
-    * allow to display bold & underlined messages *)
+ * - allow to display bold & underlined messages *)
 
 (* Store whether a message was already displayed to reset if necessary (see
  * function reset) *)
@@ -47,31 +47,31 @@ let already = ref false
 
 (* Function to keep a trace of colored messages *)
 let log_already () =
-    match !already with
-    | false -> already := true
-    | true -> ()
+  match !already with
+  | false -> already := true
+  | true -> ()
 ;;
 
 (* Types corresponding to some colors & style of the Core_extended.Color_print
  * library *)
 type color =
-    | Green
-    | Red
-    | Yellow
-    | White
-    | Plum
-    | Cyan
+  | Green
+  | Red
+  | Yellow
+  | White
+  | Plum
+  | Cyan
 ;;
 
 type style =
-    | Bold
-    | Underline
-    | Normal
+  | Bold
+  | Underline
+  | Normal
 ;;
 
 (* General function to print things *)
 let print ~color ~style message =
-    let open Core_extended in
+  let open Core_extended in
     match !Const.no_color with
     | true -> printf "%s" message
     | false -> begin (* Use colors *)
@@ -80,60 +80,60 @@ let print ~color ~style message =
         (* This code create proper escapement to display text with bold/color... *)
         color |>
         (function
-            | Green -> Color_print.color ~color:`Green message
-            | Red -> Color_print.color ~color:`Red message
-            | Yellow -> Color_print.color ~color:`Yellow message
-            | White -> Color_print.color ~color:`White message
-            | Plum -> Color_print.color ~color:`Plum message
-            | Cyan -> Color_print.color ~color:`Cyan message
+          | Green -> Color_print.color ~color:`Green message
+          | Red -> Color_print.color ~color:`Red message
+          | Yellow -> Color_print.color ~color:`Yellow message
+          | White -> Color_print.color ~color:`White message
+          | Plum -> Color_print.color ~color:`Plum message
+          | Cyan -> Color_print.color ~color:`Cyan message
         ) |> (* Finaly print escaped string *)
         (fun colored_msg ->
-            match style with
-            | Bold -> Color_print.boldprintf "%s" colored_msg
-            | Underline -> Color_print.underlineprintf "%s" colored_msg
-            | Normal -> printf "%s" colored_msg
+           match style with
+           | Bold -> Color_print.boldprintf "%s" colored_msg
+           | Underline -> Color_print.underlineprintf "%s" colored_msg
+           | Normal -> printf "%s" colored_msg
         )
-    end
+      end
 ;;
 
 (* Behave in a conform way to verbosity
  * The higher is the number, the more important the message is, the lower
  * verbosity value display it *)
 let check_verbosity ~f function_number =
-    match function_number <= !Const.verbosity with
+  match function_number <= !Const.verbosity with
     true -> (* Display the message *)
-        f ()
-    | false -> ()
+    f ()
+  | false -> ()
 ;;
 
 
 (* Print debugging, information, important... messages *)
 let debug message =
-    check_verbosity ~f:(fun () ->
-        let mess = (Time.now() |> Time.to_string) ^ " " ^ message ^ "\n" in
-        print ~color:Plum ~style:Underline mess
-    ) 5
+  check_verbosity ~f:(fun () ->
+     let mess = (Time.now() |> Time.to_string) ^ " " ^ message ^ "\n" in
+       print ~color:Plum ~style:Underline mess
+   ) 5
 ;;
 
 let info message =
-    check_verbosity ~f:(fun () ->
-        let mess = message ^ "\n" in
-        print ~color:White ~style:Normal mess
-    ) 3
+  check_verbosity ~f:(fun () ->
+     let mess = message ^ "\n" in
+       print ~color:White ~style:Normal mess
+   ) 3
 ;;
 
 let warning message =
-    check_verbosity ~f:(fun () ->
-        let mess = message ^ "\n" in
-        print ~color:Red ~style:Bold mess
-    ) 1
+  check_verbosity ~f:(fun () ->
+     let mess = message ^ "\n" in
+       print ~color:Red ~style:Bold mess
+   ) 1
 ;;
 
 (* Type for the answers *)
 type answer = Yes | No;;
 (* Usefull to display result *)
 let answer2str = function
-  Yes -> "Yes" | No -> "No"
+    Yes -> "Yes" | No -> "No"
 ;;
 (* State of the program, if you should always answer yes, no or ask to the user
  * (default)*)
@@ -149,43 +149,43 @@ let check_assume_yes ~f =
 
 (* Get confirmation
  * TODO:
-   * allow option like -y
-   * test it (display, line return, etc...) *)
+ * - allow option like -y
+ *  -test it (display, line return, etc...) *)
 let rec confirm info =
   check_assume_yes ~f:(fun () ->
-    print ~color:Cyan ~style:Normal info;
-    print ~color:Cyan ~style:Normal "\n(Yes/No): ";
-    (* XXX Be sure to show the message *)
-    Out_channel.(flush stdout);
-    let str_answer = In_channel.(input_line ~fix_win_eol:true stdin) in
-    str_answer |> (function
-      | Some "Y" | Some "y" | Some "Yes" | Some "YES" | Some "yes" -> Yes
-      | Some "N" | Some "n" | Some "No" | Some "NO" | Some "no" -> No
-      | Some _ | None ->
-        warning "Please enter 'yes' or 'no' or 'y' or 'n'.";
-        confirm info)
-    )
+     print ~color:Cyan ~style:Normal info;
+     print ~color:Cyan ~style:Normal "\n(Yes/No): ";
+     (* XXX Be sure to show the message *)
+     Out_channel.(flush stdout);
+     let str_answer = In_channel.(input_line ~fix_win_eol:true stdin) in
+       str_answer |> (function
+          | Some "Y" | Some "y" | Some "Yes" | Some "YES" | Some "yes" -> Yes
+          | Some "N" | Some "n" | Some "No" | Some "NO" | Some "no" -> No
+          | Some _ | None ->
+            warning "Please enter 'yes' or 'no' or 'y' or 'n'.";
+            confirm info)
+   )
 ;;
 
 let ok message =
-    check_verbosity ~f:(fun () ->
-        let mess = message ^ "\n" in
-        print ~color:Green ~style:Bold mess
-    ) 2
+  check_verbosity ~f:(fun () ->
+     let mess = message ^ "\n" in
+       print ~color:Green ~style:Bold mess
+   ) 2
 ;;
 
 let tips message =
-    check_verbosity ~f:(fun () ->
-    let mess = message ^ "\n" in
-    print ~color:Yellow ~style:Normal mess
-    ) 4
+  check_verbosity ~f:(fun () ->
+     let mess = message ^ "\n" in
+       print ~color:Yellow ~style:Normal mess
+   ) 4
 ;;
 
 
 (* Reset printing, to avoid color problem on some terminal (Konsole), the  *)
 let reset () =
-    match !already with
-    | true -> debug "Reseted colors";
-        Core_extended.Color_print.normal "" |> printf "%s\n"
-    | false -> debug "Not resetted"; ()
+  match !already with
+  | true -> debug "Reseted colors";
+    Core_extended.Color_print.normal "" |> printf "%s\n"
+  | false -> debug "Not resetted"; ()
 ;;

+ 25 - 25
src/remove_command.ml

@@ -41,39 +41,39 @@ open Core.Std;;
 (* Function remove nth command in the rc_file, returning the removed one and the
  * new list *)
 let remove current_list n =
-    let removed = ref "" in
-    (* The list without the nth item *)
-    let new_list = List.filteri current_list ~f:(fun i _ ->
-        if i <> n then
-            (* If it is not nth, return true *)
-            true
-        else
-            begin
-                (* If it is nth, ie the command to be removed, store it and return
-                 * false, to remove the corresponding item *)
-                removed := List.nth_exn current_list i;
-                false
-            end
-    ) in
+  let removed = ref "" in
+  (* The list without the nth item *)
+  let new_list = List.filteri current_list ~f:(fun i _ ->
+     if i <> n then
+       (* If it is not nth, return true *)
+       true
+     else
+       begin
+         (* If it is nth, ie the command to be removed, store it and return
+          * false, to remove the corresponding item *)
+         removed := List.nth_exn current_list i;
+         false
+       end
+   ) in
     ( !removed, new_list )
 ;;
 
 (* Function which add the commands (one per line) ridden on stdin to the rc
  * file, and then display th new configuration *)
 let run ~(rc:File_com.t) n_to_remove =
-    (* Get actual list of commands *)
-    let actual_list = rc.Settings_t.progs in
-    (* Get nth *)
-    let nth = Option.value n_to_remove
-        ~default:((List.length actual_list) - 1) in
-    (* Remove the nth command, after display it *)
-    let removed,new_list = remove actual_list nth in
+  (* Get actual list of commands *)
+  let actual_list = rc.Settings_t.progs in
+  (* Get nth *)
+  let nth = Option.value n_to_remove
+              ~default:((List.length actual_list) - 1) in
+  (* Remove the nth command, after display it *)
+  let removed,new_list = remove actual_list nth in
     sprintf "Removing: %s\n" removed
     |> Messages.warning;
     (* Write new list to rc file *)
     let updated_rc = { rc with Settings_t.progs = new_list } in
-    File_com.write updated_rc;
-    (* Display the result *)
-    let reread_rc = File_com.init_rc () in
-    List_rc.run ~rc:reread_rc ()
+      File_com.write updated_rc;
+      (* Display the result *)
+      let reread_rc = File_com.init_rc () in
+        List_rc.run ~rc:reread_rc ()
 ;;

+ 11 - 11
src/signals.ml

@@ -45,19 +45,19 @@ open Core.Std;;
 let handle_sigint () =
   let launch_next () =
     Messages.(confirm "Would you like to launch next command?"
-    |> function
-      | Yes -> (* Launch next *)
-        failwith "TODO Relaunch"
-      | No -> (* Quit *)
-        failwith "TODO Quit"
-    )
+              |> function
+              | Yes -> (* Launch next *)
+                failwith "TODO Relaunch"
+              | No -> (* Quit *)
+                failwith "TODO Quit"
+             )
   in
   let open Signal in
-  Expert.handle int (fun signal ->
-    if signal = int
-    then
-      launch_next ()
-    else ())
+    Expert.handle int (fun signal ->
+       if signal = int
+       then
+         launch_next ()
+       else ())
 ;;
 
 (* Called from external to activate signal handling *)

+ 15 - 15
src/state.ml

@@ -41,23 +41,23 @@ open Core.Std;;
 (* Display current number *)
 let print_current ~rc () =
   Tmp_file.(init ()
-    |> (fun tmp -> get_accurate_log ~tmp ())
-    |> Exec_cmd.less_launched_num
-    |> Tools.spy1_int_option)
+            |> (fun tmp -> get_accurate_log ~tmp ())
+            |> Exec_cmd.less_launched_num
+            |> Tools.spy1_int_option)
   |> Option.value_map
-    ~default:"Nothing next"
-    ~f:(fun ( num : int ) ->
+       ~default:"Nothing next"
+       ~f:(fun ( num : int ) ->
 
-      (* XXX Debug *)
-      sprintf "Num: %i" num |> Messages.debug;
+          (* XXX Debug *)
+          sprintf "Num: %i" num |> Messages.debug;
 
-      File_com.num_cmd2cmd ~rc num
-      |> (function
-        | Some cmd -> cmd
-        | None -> Messages.warning "Error, should not append, this is a bug";
-          assert false)
-      |> (fun ( cmd : string ) ->
-          Messages.debug cmd; (* TODO Use tools.spy1 *)
-          sprintf "Next: command %i, '%s'" num cmd))
+          File_com.num_cmd2cmd ~rc num
+          |> (function
+             | Some cmd -> cmd
+             | None -> Messages.warning "Error, should not append, this is a bug";
+               assert false)
+          |> (fun ( cmd : string ) ->
+             Messages.debug cmd; (* TODO Use tools.spy1 *)
+             sprintf "Next: command %i, '%s'" num cmd))
   |> Messages.ok
 ;;

+ 11 - 11
src/test/ec_t.ml

@@ -40,30 +40,30 @@ open Core.Std;;
 
 (* Function epur *)
 let epur () =
-    let current = Edit_command.epur [ "qw" ; "" ; "erty" ; "a" ; "" ; "zerty"] in
-    let expected = [ "qw" ; "erty" ; "a" ; "zerty" ] in
+  let current = Edit_command.epur [ "qw" ; "" ; "erty" ; "a" ; "" ; "zerty"] in
+  let expected = [ "qw" ; "erty" ; "a" ; "zerty" ] in
     OUnit.assert_equal current expected
 ;;
 
 (* Function gen_modification *)
 let gm1 () =
-    let current = Edit_command.gen_modification [ "qw" ] in
-    let expected = "qw" in
+  let current = Edit_command.gen_modification [ "qw" ] in
+  let expected = "qw" in
     OUnit.assert_equal current expected
 ;;
 
 let gm2 () =
-    let current = Edit_command.gen_modification [ "qw" ; "erty" ; "a" ; "zerty"] in
-    let expected = "\nqw\nerty\na\nzerty\n" in
+  let current = Edit_command.gen_modification [ "qw" ; "erty" ; "a" ; "zerty"] in
+  let expected = "\nqw\nerty\na\nzerty\n" in
     OUnit.assert_equal current expected
 ;;
 
 let n_l =
-    [
-        ("Remove empty strings in list", `Quick, epur);
-        ("Summary of modifications: one element", `Quick, gm1);
-        ("Summary of modifications: several elements", `Quick, gm2);
-    ]
+  [
+    ("Remove empty strings in list", `Quick, epur);
+    ("Summary of modifications: one element", `Quick, gm1);
+    ("Summary of modifications: several elements", `Quick, gm2);
+  ]
 ;;
 
 (* To be used in test.ml *)

+ 19 - 19
src/test/edit_t.ml

@@ -41,14 +41,14 @@ open Core.Std;;
 (* Function epur ============================= *)
 let epur test solution () =
   let actual = Edit_command.epur test in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Data for above test *)
 let ll_data = [
   ( [ "cmd1" ; "cmd2"; "" ], [ "cmd1" ; "cmd2" ], "Canonical case" );
   ( [ "" ; "cmd1" ; "" ; "" ; "cmd2"; "" ], [ "cmd1" ; "cmd2" ],
-  "Many empty elements, with some following" );
+    "Many empty elements, with some following" );
   ( [ "cmd1" ; "" ; "cmd2" ], [ "cmd1" ; "cmd2" ],
     "Two elements + empty ones, in the middle" );
   ( [], [], "Empty list" );
@@ -65,19 +65,19 @@ let llt_l =
 (* Function new_list ========================= *)
 let n_list ( current_list, position, new_items ) solution () =
   let actual = Edit_command.new_list current_list position new_items in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Data for above test *)
 let nl_data = [
   ( ( [ "cmd1" ; "cmd2" ; "cmd3" ], 1, ["new_cmd"] ), [ "cmd1" ; "new_cmd" ; "cmd2" ; "cmd3" ], "Canonical case 1" );
   ( ( [ "cmd1" ; "cmd2" ; "cmd3" ; "cmd4" ; "cmd5" ], 2, [ "cmd"  ; "cmd" ; "cmd" ] ),
-      [ "cmd1" ; "cmd2" ; "cmd"  ; "cmd" ; "cmd" ; "cmd3" ; "cmd4" ; "cmd5" ],
-      "Canonical case 2" );
+    [ "cmd1" ; "cmd2" ; "cmd"  ; "cmd" ; "cmd" ; "cmd3" ; "cmd4" ; "cmd5" ],
+    "Canonical case 2" );
   ( ( [ "cmd1" ; "cmd2" ; "cmd3" ], 0, ["new_cmd"] ), [ "new_cmd" ; "cmd1" ;
-  "cmd2" ; "cmd3" ], "Insert on top" );
+                                                        "cmd2" ; "cmd3" ], "Insert on top" );
   ( ( [ "cmd1" ; "cmd2" ; "cmd3" ; "cmd4" ; "cmd5" ], 4, ["new_cmd"] ), [ "cmd1"
-  ; "cmd2" ; "cmd3" ; "cmd4" ; "new_cmd" ; "cmd5" ], "Insert bottom" );
+                                                                        ; "cmd2" ; "cmd3" ; "cmd4" ; "new_cmd" ; "cmd5" ], "Insert bottom" );
   ( ( [], 0, [] ), [], "Empty list" );
   ( ( [], 0, [ "new" ; "element" ] ), [ "new" ; "element" ], "Insertion of new elements in an empty list" );
   ( ( [], 5, [ "new" ; "element" ] ), [ "new" ; "element" ], "Out of bound (inserting elements)" );
@@ -89,14 +89,14 @@ let big =
     "Big list",
     `Slow,
     (fun () ->
-      let l = List.init 1_000_000 ~f:(fun a -> a) in
-      let pos = 5 in
-      let actual = Edit_command.new_list l pos [ -2 ; -1 ] in
-      let conformity li =
-        ((List.nth_exn li pos) = -2) &&
-        ((List.nth_exn li (succ pos)) = -1)
-      in
-      OUnit.assert_bool "My test" (conformity actual)
+       let l = List.init 1_000_000 ~f:(fun a -> a) in
+       let pos = 5 in
+       let actual = Edit_command.new_list l pos [ -2 ; -1 ] in
+       let conformity li =
+         ((List.nth_exn li pos) = -2) &&
+         ((List.nth_exn li (succ pos)) = -1)
+       in
+         OUnit.assert_bool "My test" (conformity actual)
     )
   )
 ;;
@@ -110,7 +110,7 @@ let lt_l =
 (* Function gen_modification ================ *)
 let gen_mod test solution () =
   let actual = Edit_command.gen_modification test in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Data for above test *)
@@ -132,9 +132,9 @@ let gmt_l =
 
 (* To be used in test.ml *)
 let alco = [( "Edit_command.ml: Epur", llt_l ) ;
-  ( "Edit_command.ml.New list", ( big :: lt_l ) ) ;
-  ( "Edit_command.ml.Modification summary", gmt_l )
-];;
+            ( "Edit_command.ml.New list", ( big :: lt_l ) ) ;
+            ( "Edit_command.ml.Modification summary", gmt_l )
+           ];;
 
 
 

+ 23 - 23
src/test/exec_t.ml

@@ -41,13 +41,13 @@ open Core.Std;;
 (* Function less_launched *)
 let less_launched test solution () =
   let actual = Exec_cmd.less_launched test in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Function less_launched_num *)
 let less_launched_num test solution () =
   let actual = Exec_cmd.less_launched_num test in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Maximum number of launch *)
@@ -67,21 +67,21 @@ let common_data =
       "Everything (strictly) superior to maximum" );
     (* To prevent >= and > misuse in code *)
     ( [ ( "cmd1", max - 1 ) ; ( "cmd2", max ) ; ( "cmd3", max + 1 ) ;
-      ( "cmd3", max + 2) ], "Around maximum (ordered)" );
+        ( "cmd3", max + 2) ], "Around maximum (ordered)" );
     ( [ ( "cmd1", max + 1 ) ; ( "cmd2", max ) ; ( "cmd3", max - 1 ) ;
-      ( "cmd3", max + 2) ], "Around maximum (disordered)" )
+        ( "cmd3", max + 2) ], "Around maximum (disordered)" )
   ]
 ;;
 (* Add expected result to corresponding to the data provided common set *)
 let add_solutions data expected =
   List.map2_exn data expected ~f:(fun ( log, name ) solution ->
-    ( log, solution, name ))
+     ( log, solution, name ))
 ;;
 
 (* Data customized for the tests *)
 let ll_data =
   add_solutions common_data
-  [
+    [
       Some "cmd2";
       Some "cmd1";
       None;
@@ -91,41 +91,41 @@ let ll_data =
       None;
       Some "cmd1";
       Some "cmd3"
-  ]
+    ]
 ;;
 let ll_data2 =
   add_solutions common_data
-  [
-    Some 1;
-    Some 0;
-    None;
-    Some 0;
-    Some 0;
-    None;
-    None;
-    Some 0;
-    Some 2
-  ]
+    [
+      Some 1;
+      Some 0;
+      None;
+      Some 0;
+      Some 0;
+      None;
+      None;
+      Some 0;
+      Some 2
+    ]
 ;;
 
 let llt_l =
   let less_launched_suit =
     List.map ll_data ~f:(fun (t, s, name) -> ( (less_launched t s), name))
   in
-  less_launched_suit
-  |> List.map ~f:(fun ( f,name ) -> (name, `Quick, f))
+    less_launched_suit
+    |> List.map ~f:(fun ( f,name ) -> (name, `Quick, f))
 ;;
 
 let llt_l2 =
   let less_launched_num_suit =
     List.map ll_data2 ~f:(fun (t, s, name) -> ( (less_launched_num t s), name))
   in
-  less_launched_num_suit
-  |> List.map ~f:(fun ( f,name ) -> (name, `Quick, f))
+    less_launched_num_suit
+    |> List.map ~f:(fun ( f,name ) -> (name, `Quick, f))
 ;;
 
 (* To be used in test.ml *)
 let alco = [( "Exec_cmd.ml.less_launched", llt_l ) ;
-  ( "Exec_cmd.ml.less_launched_num", llt_l2 )];;
+            ( "Exec_cmd.ml.less_launched_num", llt_l2 )];;
 
 

+ 2 - 2
src/test/test.ml

@@ -39,6 +39,6 @@ open Core.Std;;
 (* A module launching all tests *)
 
 let () =
-    Alcotest.run "Test suite for the project"
-        (List.concat [ Ec_t.alco ; Exec_t.alco ; Edit_t.alco ; Unify_t.alco ])
+  Alcotest.run "Test suite for the project"
+    (List.concat [ Ec_t.alco ; Exec_t.alco ; Edit_t.alco ; Unify_t.alco ])
 ;;

+ 16 - 16
src/test/unify_t.ml

@@ -41,7 +41,7 @@ open Core.Std;;
 (* Function make_uniq ============================= *)
 let make_uniq test solution () =
   let actual = Unify.make_uniq test in
-  OUnit.assert_equal actual solution
+    OUnit.assert_equal actual solution
 ;;
 
 (* Big and sometimes strange list, to be used in test data set.
@@ -51,13 +51,13 @@ let make_uniq test solution () =
 let big_unique length = (* Long list of unique elements *)
   let message = "unique element" in
   let test_case = List.init ~f:(fun i -> Int.to_string i) length in
-  ( test_case, test_case, message )
+    ( test_case, test_case, message )
 ;;
 let big_same length = (* Long list of unique elements *)
   let message = "all the same element" in
   let same_element = "cmd1" in
   let test_case = List.init ~f:(fun i -> same_element) length in
-  ( test_case, [ same_element ], message )
+    ( test_case, [ same_element ], message )
 ;;
 let big_periodic length = (* Long list of unique elements *)
   let message = "periodically the same element" in
@@ -66,19 +66,19 @@ let big_periodic length = (* Long list of unique elements *)
   let dbl = length + 42 |> Int.to_string in
   let sol = ref [] in
   let test_case = List.init ~f:(fun i ->
-    if i mod periode = 0
-    then dbl
-    else Int.to_string i
-    (* Keep for the solution *)
-    |> (fun t -> sol := t :: !sol; t)) length
+     if i mod periode = 0
+     then dbl
+     else Int.to_string i
+          (* Keep for the solution *)
+          |> (fun t -> sol := t :: !sol; t)) length
   in
-  ( test_case, dbl :: !sol, message )
+    ( test_case, dbl :: !sol, message )
 ;;
 let big_long_entry length = (* Long list of unique elements *)
   let message = "long unique element" in
   let test_case = List.init ~f:(fun i -> "Longer entries, numbered thouth. This one is number \
-  is: " ^ (Int.to_string i)) length in
-  ( test_case, test_case, message )
+                                          is: " ^ (Int.to_string i)) length in
+    ( test_case, test_case, message )
 ;;
 (* Function packing the preceding *)
 let big_pack ~message length =
@@ -98,14 +98,14 @@ let make_uniq_data = [
   ( [ "cmd1" ; "cmd2"; "" ; "cmd1" ], [ "cmd1" ; "cmd2"; ""], "Canonical case" );
   (* Make sure no reordering is appening *)
   ( [ "cmd33" ; "cmd2" ; "" ; "" ; "cmd1"; "" ], [ "cmd33" ; "cmd2" ; "" ; "cmd1" ],
-  "Test order" );
+    "Test order" );
   ( [ "cmd1" ; "" ; "cmd2" ], [ "cmd1" ; "" ; "cmd2" ],
     "No duplicate" );
   ( [], [], "Empty list" );
 ]
-(* Speed is an important aspect, test it. *)
-@ (big_pack ~message:"Quite small list of " 10)
-@ (big_pack ~message:"Practically max length list of " 100)
+  (* Speed is an important aspect, test it. *)
+  @ (big_pack ~message:"Quite small list of " 10)
+  @ (big_pack ~message:"Practically max length list of " 100)
 ;;
 
 let t_set_fast =
@@ -116,7 +116,7 @@ let t_set_fast =
 let t_set_long =
   List.map
     ((big_pack ~message:"Much longer than real use case list of " 1_000)
-    @ (big_pack ~message:"Crazy long list of " 9_999))
+     @ (big_pack ~message:"Crazy long list of " 9_999))
     ~f:(fun (t, s, name) -> ( (make_uniq t s), name))
   |> List.map ~f:(fun ( f,name ) -> (name, `Slow, f))
 ;;

+ 59 - 59
src/tmp_file.ml

@@ -41,38 +41,38 @@ type t = Tmp_biniou_t.tmp_file;;
 
 (* Function to write the tmp file *)
 let write (tmp_file:t) =
-    (* Short name *)
-    let name = Const.tmp_file in
-    let biniou_tmp = Tmp_biniou_b.string_of_tmp_file tmp_file in
+  (* Short name *)
+  let name = Const.tmp_file in
+  let biniou_tmp = Tmp_biniou_b.string_of_tmp_file tmp_file in
     Out_channel.write_all name ~data:biniou_tmp
 ;;
 
 (* XXX Using and keyword because each function can call each other *)
 (* Function to read the tmp file *)
 let rec read () =
-    (* Short name *)
-    let name = Const.tmp_file in
-    (* Get the string corresponding to the file *)
-    let file_content = In_channel.read_all name in
+  (* Short name *)
+  let name = Const.tmp_file in
+  (* Get the string corresponding to the file *)
+  let file_content = In_channel.read_all name in
     try
-        Tmp_biniou_b.tmp_file_of_string file_content
+      Tmp_biniou_b.tmp_file_of_string file_content
     (* In previous version, the JSON format was used, otherwise the file can
      * have a bad format. In this case, the Ag_ob_run.Error("Read error (1)")
      * exeption is throw. We catch it here *)
     with _ ->
-        (* If file is not in the right format, delete it and create a new one.
-         * Then, read it *)
-        Messages.ok "Reinitialises tmp file\n";
-        Sys.remove name;
-        create_tmp_file ();
-        read ()
+      (* If file is not in the right format, delete it and create a new one.
+       * Then, read it *)
+      Messages.ok "Reinitialises tmp file\n";
+      Sys.remove name;
+      create_tmp_file ();
+      read ()
 
 (* Function to create the tmp file *)
 and create_tmp_file () =
-    (* An empty list, without rc, commands, launch... *)
-    Tmp_biniou_v.create_tmp_file ~daemon:0 ~rc:[] ()
-    (* Convert it to biniou *)
-    |> write
+  (* An empty list, without rc, commands, launch... *)
+  Tmp_biniou_v.create_tmp_file ~daemon:0 ~rc:[] ()
+  (* Convert it to biniou *)
+  |> write
 ;;
 
 (* Function to open tmp file *)
@@ -80,36 +80,36 @@ let rec init () =
   (* If file do not exists, create it *)
   let file_exists = Sys.file_exists Const.tmp_file in
     match file_exists with
-      | `No -> create_tmp_file ();
-          init ()
-      | `Unknown -> begin
-          Sys.remove Const.tmp_file;
-          init ()
-        end
-      | `Yes -> read ()
+    | `No -> create_tmp_file ();
+      init ()
+    | `Unknown -> begin
+        Sys.remove Const.tmp_file;
+        init ()
+      end
+    | `Yes -> read ()
 ;;
 
 (* Get a log of values from the tmp file, like this
  * (cmd,number of launch) list *)
 let get_log ~rc_tmp =
   List.map ~f:(fun { Tmp_biniou_t.commands = (cmd,number) } ->
-        (cmd,number)) rc_tmp
+     (cmd,number)) rc_tmp
 ;;
 
 (* Verify that the value exist *)
 let verify_key_exist ~key entry =
-    if entry = key then
-        true
-    else
-        false
+  if entry = key then
+    true
+  else
+    false
 ;;
 
 (* Return true if a program is in the rc file *)
 let rec is_prog_in_rc list_from_rc_file program =
-    match list_from_rc_file with
-    (* | None -> is_prog_in_rc program ~liste_from_rc_file:rc_content.progs *)
-    | [] -> false
-    | hd :: tl -> if hd = program then true else is_prog_in_rc tl program
+  match list_from_rc_file with
+  (* | None -> is_prog_in_rc program ~liste_from_rc_file:rc_content.progs *)
+  | [] -> false
+  | hd :: tl -> if hd = program then true else is_prog_in_rc tl program
 ;;
 
 (* Log when a program has been launched in a file in /tmp
@@ -125,27 +125,27 @@ let log ~cmd ?(func= (+) 1 ) () =
     let open List.Assoc in
     (* Only number of launch associated with commands *)
     let l = get_log ~rc_tmp:li in
-    find l cmd
+      find l cmd
       |> (function None -> add l cmd Const.default_launch | Some n -> add l cmd (func n))
       |> List.map ~f:(fun e -> { Tmp_biniou_t.commands = e})
-    in
+  in
   (* Write the file with the new value *)
   let updated_li =
     List.Assoc.(find file.Tmp_biniou_t.rc name)
-      |> Option.value ~default:[]
-      |> new_li
+    |> Option.value ~default:[]
+    |> new_li
   in
-  write Tmp_biniou_t.{ file with rc = List.Assoc.add file.rc name
-  updated_li }
+    write Tmp_biniou_t.{ file with rc = List.Assoc.add file.rc name
+                                          updated_li }
 ;;
 
 (* Return current number *)
 let get_current () =
-    failwith "Deprecated"
+  failwith "Deprecated"
 ;;
 
 (* Get number of launch for each command in rc file, as follow:
-  * (command:string, number of the command:int) list *)
+ * (command:string, number of the command:int) list *)
 let get_accurate_log ?rc_name ~tmp () =
   let open List in
 
@@ -157,12 +157,12 @@ let get_accurate_log ?rc_name ~tmp () =
   let rc =  File_com.init_rc ~rc:(Lazy.return name) () in
 
   let rc_in_tmp = get_log ~rc_tmp:(Assoc.find tmp.Tmp_biniou_t.rc name
-    |> Option.value ~default:[])
+                                   |> Option.value ~default:[])
   in
-  map rc.Settings_t.progs ~f:(fun key ->
-        Assoc.find rc_in_tmp key
-    |> Option.value ~default:0
-    |> (function number -> (key,number)))
+    map rc.Settings_t.progs ~f:(fun key ->
+       Assoc.find rc_in_tmp key
+       |> Option.value ~default:0
+       |> (function number -> (key,number)))
 ;;
 
 (* Reset number of launch for a given command
@@ -171,8 +171,8 @@ let get_accurate_log ?rc_name ~tmp () =
 let reset_cmd ~rc num cmd =
   (* Debugging *)
   [(num,"num") ; (cmd,"cmd")]
-    |> List.map ~f:(fun (i , str) -> str ^ ": " ^ (Int.to_string i))
-    |> List.iter ~f:(fun s -> Messages.debug s);
+  |> List.map ~f:(fun (i , str) -> str ^ ": " ^ (Int.to_string i))
+  |> List.iter ~f:(fun s -> Messages.debug s);
 
   let ac_log = get_accurate_log ~tmp:(init ()) () in
   (* The command (string) corresponding to the number *)
@@ -180,7 +180,7 @@ let reset_cmd ~rc num cmd =
     File_com.num_cmd2cmd ~rc cmd
     |> function
       Some s -> s
-      | None -> failwith "Out of bound"
+    | None -> failwith "Out of bound"
   in
 
   (* Current number of launch for that cmd *)
@@ -206,9 +206,9 @@ let reset2num ~rc num =
 
   let ac_log = get_accurate_log ~tmp:(init ()) () in
 
-  (* Erase number of launch for each command *)
-  List.iter ac_log ~f:(fun ( cmd, _ ) ->
-    log ~func:(fun _ -> num) ~cmd ())
+    (* Erase number of launch for each command *)
+    List.iter ac_log ~f:(fun ( cmd, _ ) ->
+       log ~func:(fun _ -> num) ~cmd ())
 ;;
 
 (* Reset all command *)
@@ -219,14 +219,14 @@ let reset_all () =
     let tmp = init () in
     (* Get rc_file name *)
     let name = Lazy.force !Const.rc_file in
-    write Tmp_biniou_t.{ tmp with rc = List.Assoc.add tmp.rc name [] }
+      write Tmp_biniou_t.{ tmp with rc = List.Assoc.add tmp.rc name [] }
   in
-  Messages.debug "Asking question";
-  Messages.confirm "You will lose number of launch for every command.\
-    Are you sure?"
-  |> (fun answer -> sprintf "Answer %s" (Messages.answer2str answer) |> Messages.debug; answer) (* Spy *)
+    Messages.debug "Asking question";
+    Messages.confirm "You will lose number of launch for every command.\
+                      Are you sure?"
+    |> (fun answer -> sprintf "Answer %s" (Messages.answer2str answer) |> Messages.debug; answer) (* Spy *)
     |> function
       Messages.Yes -> reset_without_ask ()
-      | Messages.No -> ()
+    | Messages.No -> ()
 ;;
 

+ 11 - 11
src/tools.ml

@@ -55,10 +55,10 @@ let spy1_int i =
 ;;
 let spy1_int_option io =
   let i = io |> (function
-    None -> "None"
-    | Some i -> sprintf "Some %i" i)
+       None -> "None"
+     | Some i -> sprintf "Some %i" i)
   in
-  spy io i
+    spy io i
 ;;
 let spy1_string str =
   spy str str
@@ -69,19 +69,19 @@ let spy1_float f =
 ;;
 let spy1_list ~f list =
   let list_str = List.map list ~f:(fun element ->
-    sprintf "\"%s\"; " (f element))
+     sprintf "\"%s\"; " (f element))
   in
-  "[ " ^ (String.concat list_str) ^ " ]"
-  |> printing;
-  list
+    "[ " ^ (String.concat list_str) ^ " ]"
+    |> printing;
+    list
 ;;
 let spy1_log (log : (string * int) list) =
   let log_str = List.map log ~f:(fun (s, i) ->
-    sprintf "( \"%s\", %i ); " s i)
+     sprintf "( \"%s\", %i ); " s i)
   in
-  "[ " ^ (String.concat log_str) ^ " ]"
-  |> printing;
-  log
+    "[ " ^ (String.concat log_str) ^ " ]"
+    |> printing;
+    log
 ;;
 let spy1_rc rc =
   failwith "Not implemented"

+ 21 - 21
src/unify.ml

@@ -47,12 +47,12 @@ open Core.Std;;
  * internally *)
 let make_uniq dubbled_entries =
   let seen = ref [] in (* Entries already added *)
-  List.(filter dubbled_entries ~f:(fun entry ->
-    (exists !seen ~f:(fun in_seen -> in_seen = entry)) |> function
-      | false -> (* Entry not already seen, keep it *)
-        seen := (entry :: !seen); true
-      (* Already kept, discard *)
-      | true -> false))
+    List.(filter dubbled_entries ~f:(fun entry ->
+       (exists !seen ~f:(fun in_seen -> in_seen = entry)) |> function
+       | false -> (* Entry not already seen, keep it *)
+         seen := (entry :: !seen); true
+       (* Already kept, discard *)
+       | true -> false))
 ;;
 
 (* Remove doubled or void entries in a list. Commands are cleanup (removing
@@ -60,26 +60,26 @@ let make_uniq dubbled_entries =
 (* TODO Test it separatly, reusing tests from edit_command.ml *)
 let prettify_cmd cmds =
   let without_lr =
-  (* Removing line return, and trailing spaces, at the end or
-  at the start of a command *)
+    (* Removing line return, and trailing spaces, at the end or
+       at the start of a command *)
     List.filter_map cmds ~f:(fun str ->
-      trim str |> function
-        | "" ->
-          Messages.debug "Trimmed command";
-          None
-        | s -> Some s)
+       trim str |> function
+       | "" ->
+         Messages.debug "Trimmed command";
+         None
+       | s -> Some s)
   in
 
   (* Remove doubled entries *)
   let unified_rc = make_uniq without_lr in
 
-  (* Display whether duplicates were found *)
-  if List.(length unified_rc = length without_lr) then
-    Messages.debug "No duplicate found"
-  else
-    Messages.debug "Duplicate found, removed";
+    (* Display whether duplicates were found *)
+    if List.(length unified_rc = length without_lr) then
+      Messages.debug "No duplicate found"
+    else
+      Messages.debug "Duplicate found, removed";
 
-  unified_rc
+    unified_rc
 ;;
 
 (* Removing doubled entries (cmds). We need to remove carriage return before
@@ -88,7 +88,7 @@ let prettify_cmd cmds =
 let prettify rc_file =
   let cmds = rc_file.Settings_v.progs in
   let unique = prettify_cmd cmds in
-  (* Store the deduplicated list in new rc_file *)
-  {rc_file with Settings_v.progs = unique}
+    (* Store the deduplicated list in new rc_file *)
+    {rc_file with Settings_v.progs = unique}
 ;;