unison

Fork of Unison, a bi-directional file synchronization tool
git clone git://git.laack.co/unison.git
Log | Files | Refs | README | LICENSE

pred.mli (3081B)


      1 (* Unison file synchronizer: src/pred.mli *)
      2 (* Copyright 1999-2020, Benjamin C. Pierce (see COPYING for details) *)
      3 
      4 (* Predicates over paths.
      5 
      6    General description:
      7 
      8    A predicate is determined by a list of default patterns and a list of
      9    current patterns.  These patterns can be modified by
     10    [addDefaultPatterns] and [intern].  Function [test p s] tests whether
     11    string [s] satisfies predicate [p], i.e., it matches a pattern of [p].
     12 
     13    For efficiency, the list of patterns are compiled into a regular
     14    expression.  Function [test] compares the current value of default
     15    patterns and current patterns against the save ones (recorded in
     16    last_pref/last_def) to determine whether recompilation is necessary.
     17 
     18    Each pattern has the form
     19      <TYPE> <PAT> [ -> <ASSOCIATED STRING> ]
     20    The associated string is ignored by [test] but can be looked up by [assoc].
     21 
     22    Three forms of <TYPE>/<PAT> are recognized:
     23    "Name <name>": ..../<name> (using globx)
     24    "Path <path>": <path>, not starting with "/" (using globx)
     25    "Regex <regex>": <regex> (using rx)
     26 *)
     27 
     28 
     29 type t
     30 
     31 val mapSeparator : string
     32 
     33 (* Create a new predicate and register it with the preference module. *)
     34 val create :
     35     string               (* Name of the predicate *)
     36  -> category:Prefs.group
     37  -> ?local:bool
     38  -> ?send:(unit -> bool)
     39  -> ?initial:string list (* Initial value for the "current patterns", separate
     40                             from the persistent default patterns that are
     41                             modified by [addDefaultPatterns]. User preferences
     42                             will be added to this value, but this value is not
     43                             persistent when the associated preference is cleared
     44                             (for example, [intern] will overwrite it). This
     45                             value will be returned by [extern] (if it hasn't
     46                             been cleared before). *)
     47  -> string               (* Full (latex) documentation *)
     48  -> t
     49 
     50 (* Check whether a given path matches one of the default or current patterns *)
     51 val test : t -> string -> bool
     52 
     53 (* Return the associated string for the first matching pattern.  Raise Not_found
     54    if no pattern with an associated string matches. *)
     55 val assoc : t -> string -> string
     56 
     57 (* Return all strings associated to a matching pattern. *)
     58 val assoc_all : t -> string -> string list
     59 
     60 (* Add list of default patterns to the existing list.  (These patterns are
     61    remembered even when the associated preference is cleared). *)
     62 val addDefaultPatterns : t -> string list -> unit
     63 
     64 (* Install a new list of patterns, overriding the current list *)
     65 val intern : t -> string list -> unit
     66 
     67 (* Return the current list of patterns *)
     68 val extern : t -> string list
     69 
     70 (* Return the current list of associated strings *)
     71 val extern_associated_strings : t -> string list
     72 
     73 (* Create an alternate name for a predicate (the new name will not appear
     74    in usage messages or generated documentation) *)
     75 val alias : t                 (* existing predicate *)
     76          -> string            (* new name *)
     77          -> unit