|
@@ -62,6 +62,7 @@ let new_list current_list position new_items =
|
|
|
let gen_modification items =
|
|
|
let r = "\n" in
|
|
|
epur items
|
|
|
+ |> List.map ~f:(fun entry -> entry#command)
|
|
|
|> (function
|
|
|
| [] -> ""
|
|
|
(* Only one element *)
|
|
@@ -74,9 +75,9 @@ let gen_modification items =
|
|
|
|
|
|
(* Function which get the nth element, put it in a file, let the user edit it,
|
|
|
* and then replace with the result *)
|
|
|
-let rec run ~(rc:File_com.t) position =
|
|
|
+let rec run ~(rc:Rc.t) position =
|
|
|
(* Current list of commands *)
|
|
|
- let current_list = rc.Settings_t.progs in
|
|
|
+ let current_list = rc#entries in
|
|
|
|
|
|
(* Creating tmp file, for editing *)
|
|
|
let tmp_filename = [
|
|
@@ -104,10 +105,16 @@ let rec run ~(rc:File_com.t) position =
|
|
|
|> Messages.warning);
|
|
|
|
|
|
(* Reading and applying the result *)
|
|
|
- let new_commands = In_channel.read_lines tmp_filename |> 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;
|
|
|
+ let new_commands =
|
|
|
+ In_channel.read_lines tmp_filename
|
|
|
+ |> List.map ~f:(fun command -> new Rc.entry command)
|
|
|
+ |> epur
|
|
|
+ in
|
|
|
+ let cmd_list =
|
|
|
+ new_list shorter_list position new_commands
|
|
|
+ in
|
|
|
+ let updated_rc = rc#change_entries cmd_list in
|
|
|
+ updated_rc#write;
|
|
|
(* 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
|
|
@@ -127,7 +134,7 @@ let rec run ~(rc:File_com.t) position =
|
|
|
begin
|
|
|
sprintf "'%s' -> '%s'\n" original_command new_cmd_mod |> Messages.ok;
|
|
|
(* Display new rc file *)
|
|
|
- let reread_rc = File_com.init_rc () in
|
|
|
+ let reread_rc = Rc.init () in
|
|
|
List_rc.run ~rc:reread_rc ()
|
|
|
end;
|
|
|
;;
|