Source file customization_intf.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
(** [(Info-goto-node "(elisp)Customization")] *)

open! Core
open! Import

module type Enum_arg = sig
  type t [@@deriving compare, enumerate, sexp_of]

  val docstring : t -> string
  val to_symbol : t -> Symbol.t
end

module type Enum = sig
  type t
  type 'a customization

  include Valueable.S with type t := t

  val customization : t customization
end

module type Customization = sig
  module Group : sig
    type t [@@deriving sexp_of]

    include Valueable.S with type t := t

    val emacs : t
    val ecaml : t

    (** Define a new customization group.

        [(describe-function 'defgroup)]
        [(Info-goto-node "(elisp)Group Definitions")] *)
    val defgroup
      :  string
      -> Source_code_position.t
      -> docstring:string
      -> parents:t list
      -> t

    (** Reference an already-existing customization group. *)
    val of_string : string -> t

    val to_string : t -> string
    val to_symbol : t -> Symbol.t
  end


  (** [(Info-goto-node "(elisp)Customization Types")] *)
  module Type : sig
    type t =
      | Alist of t * t
      | Boolean
      | Character
      | Choice of t list
      | Coding_system
      | Color
      | Cons of t * t
      | Const of Value.t
      | Directory
      | Existing_file
      | Face
      | File
      | Float
      | Function
      | Group of t
      | Hook
      | Integer
      | Key_sequence
      | List of t list
      | Number
      | Option of string * t
      | Plist
      | Radio of t list
      | Regexp
      | Repeat of t
      | Set of t list
      | Sexp
      | String
      | Symbol
      | Tagged_string of string
      | Variable
      | Vector of t list
    [@@deriving sexp_of]

    val enum : 'a list -> ('a -> Value.t) -> t
  end

  type 'a t [@@deriving sexp_of]

  val value : 'a t -> 'a
  val set_value : 'a t -> 'a -> unit
  val set_value_temporarily : 'a t -> 'a -> f:(unit -> 'b) -> 'b
  val var : 'a t -> 'a Var.t
  val symbol : _ t -> Symbol.t
  val name : _ t -> string
  val standard_value : 'a t -> 'a

  (** [(describe-function 'defcustom)]
      [(Info-goto-node "(elisp)Variable Definitions")]

      [on_set], if supplied, is called when the user attempts to set the customization,
      either via the customization interface or via [custom-set-variables].  [on_set]
      can validate the input and perform other side effects needed to keep OCaml
      data structures in sync with the setting.  If [on_set] raises, the customization
      is not set. *)
  val defcustom
    :  ?show_form:bool (** default is [false] *)
    -> Symbol.t
    -> Source_code_position.t
    -> docstring:string
    -> group:Group.t
    -> type_:'a Value.Type.t
    -> customization_type:Type.t
    -> standard_value:'a
    -> ?on_set:('a -> unit)
    -> unit
    -> 'a t

  module Wrap : Var.Wrap with type 'a t := 'a t

  (** [(describe-function 'customize-variable)]
      [(Info-goto-node "(emacs)Specific customization")] *)
  val customize_variable : Symbol.t -> unit

  (** [(describe-function 'customize-group)]
      [(Info-goto-node "(emacs)Specific customization")] *)
  val customize_group : Group.t -> unit

  module type Enum_arg = Enum_arg

  val defcustom_enum
    :  Symbol.t
    -> Source_code_position.t
    -> (module Enum_arg with type t = 'a)
    -> docstring:string
    -> group:Group.t
    -> standard_value:'a
    -> ?on_set:('a -> unit)
    -> unit
    -> 'a t

  module Private : sig
    val all_defcustom_symbols : unit -> Symbol.t list
    val all_defgroups : unit -> Group.t list
  end
end