let load_file args =
if Array.length args < 1 then
match !Ed_gui.active_window with
None -> ()
| Some w ->
let f file =
Cam_commands.launch_command "load_file" [| file |]
in
let mb = w#minibuffer in
Ed_misc.select_file
mb ~title: "load_file"
""
f
else
(
let file = args.(0) in
let code = Printf.sprintf "#load \"%s\";;" file in
eval_ocaml [| code |]
(* this does not work, because Symtable.Error may be raised
and we can't print the error message since Bytecomp interface is not
installed by ocaml
let buf = Buffer.create 256 in
let fmt = Format.formatter_of_buffer buf in
let success = Topdirs.load_file fmt file in
if success then
Ed_misc.set_active_action_message
(Printf.sprintf "Successfully loaded file %s" file)
else
Ed_misc.set_active_action_message
(Printf.sprintf "Failed to load file %s" file)
*)
)