Module Ed_misc (.ml)


module Ed_misc: sig .. end
Misc functions.

val mod_date_of_file : string -> float
mod_date_of_file file returns the Unix last modification date of the given file, or 0.0 if the date could not be obtained.
val string_of_file : string -> string
string_of_file filename returns the content of filename in the form of one string.
Author(s): Maxence Guesdon
Version: 1.0
Raises Sys_error if the file could not be opened.
val file_of_string : file:string -> string -> unit
file_of_string ~file str creates a file named filename whose content is str.
Author(s): Fabrice Lefessant
Version: 1.1
Raises Sys_error if the file could not be opened.
val string_of_bool : bool -> string
val bool_of_string : string -> bool
val split_string : ?keep_empty:bool -> string -> char list -> string list
Separate the given string according to the given list of characters.
Author(s): Maxence Guesdon
Version: 1.1
keep_empty : is false by default. If set to true, the empty strings between separators are kept.
val safe_remove_file : string -> unit
Remove the given file, and ignore the error if the file does not exist (catch Sys_error).
Version: 1.0
val make_list : int -> 'a -> 'a list
make_list n ele builds a list of n elements ele.
Author(s): Maxence Guesdon
Version: 1.0
val no_blanks : string -> string
no_blanks s returns the given string without any blank characters, i.e. '\n' '\r' ' ' '\t'.
Version: 1.0
val date_of_file : string -> float option
date_of_file file returns the unix date of the last modification of the file, is the file can be accessed.
val try_finalize : ('a -> 'b) -> 'a -> ('c -> unit) -> 'c -> 'b
try_finalize f x g y applies f to x and return the result or raises an exception, but in all cases g is applied to y before returning or raising the exception.
Author(s): Didier Rémy
Version: 1.0
val catch_print_exceptions : ('a -> unit) -> 'a -> unit
catch_print_exception f v applies f to v and catch and print any raised exception to stderr.
val to_utf8 : ?coding:string -> string -> string
Encode the given string to UTF-8, using the default charset Ed_core_rc.default_encoding or the given coding.
val of_utf8 : ?coding:string -> string -> string
Decode the given string from UTF-8, using the default charset Ed_core_rc.default_encoding or the given coding.
val read_xml_file : string -> (Xml.xml -> 'a) -> 'a
read_xml_file file f reads the file to get an xml tree and applies f on the xml tree.
val same_files : string -> string -> bool
Return whether the two given filename identifies the same file (same device and inode).
Raises Failure if information about a file cannot be accessed.
val safe_same_files : string -> string -> bool
Same as Ed_misc.same_files but returns false instead of raising an exception if information about one file could not be retrieved.
val set_active_state_message : string -> unit
This function calls the "set_active_state_message" command with the given utf-8 string.
val set_active_action_message : string -> unit
This function calls the "set_active_action_message" command with the given utf-8 string.
val display_message : string -> unit
This function displays the given message with Cam_hooks.display_message and calls the "set_active_action_message" command with the given utf-8 string.
val warning_message : string -> unit
This function displays the given message with Cam_hooks.warning_message and calls the "set_active_action_message" command with the given utf-8 string.
val error_message : string -> unit
This function displays the given message with Cam_hooks.error_message and calls the "set_active_action_message" command with the given utf-8 string.
val fail_if_unix_error : ('a -> 'b) -> 'a -> 'b
fail_if_unix_error f x applies f to x and catches only exception Unix.Unix_error. If such an exception is raised by f, create a message string and raise Failure message.
val is_prefix : string -> string -> bool
is_prefix s1 s2 returns whether s2 is a prefix of s1.
val dir_entries : ?prefix:string -> string -> string list
dir_entries dir return the list of entries in directory dir.
prefix : can be used to filter only entries with the given prefix.
val max_common : string list -> string option
max_common strings return the longest string common to all the given strings or None if strings is the empty list.

Input functions

The strings given in parameter to the following input functions must be utf-8 encoded; the strings passed to the given callback function is decoded from utf-8 before.

val select_file_history : Ed_minibuffer.minibuffer_history
The minibuffer history used in function Ed_misc.select_file.
val select_file : Ed_minibuffer.minibuffer ->
title:string -> string -> (string -> unit) -> unit
select_file mb ~title default_text f makes the user select a file in the minibuffer and calls f with the selected file when user validates.
val select_string : ?history:Ed_minibuffer.minibuffer_history ->
Ed_minibuffer.minibuffer ->
title:string -> choices:string list -> string -> (string -> unit) -> unit
select_string mb ~title ~choice default_text f makes the user choose a string among the given choices and then calls f with the choices when the user validates.
val input_string : ?history:Ed_minibuffer.minibuffer_history ->
Ed_minibuffer.minibuffer ->
title:string -> string -> (string -> unit) -> unit
input_string mb ~title default_text f makes the user enter a text and calls f on that text when the user validates.
val input_command_arg : Ed_minibuffer.minibuffer ->
?history:Ed_minibuffer.minibuffer_history ->
title:string -> (string -> unit) -> string -> string array -> unit
FIXME: explain this
val confirm : Ed_minibuffer.minibuffer -> string -> (unit -> unit) -> unit
confirm mb question f makes the user answer to the given question and calls f if the response is "yes"
val choice_in_list : ('a -> unit) -> (string * 'a) list -> unit
choice_in_list list f pops up a menu to make the user select an entry in the menu. Then f is called on the data associated to the entry.