(*s: core/globals.ml *)
(*s: copyright header efuns *)
(***********************************************************************)
(*                                                                     *)
                                                                 
(*                                                                     *)
        Fabrice Le Fessant , projet Para / SOR , INRIA Rocquencourt       
(*                                                                     *)
   Copyright 1999 Institut National de Recherche en Informatique et   
   Automatique .   Distributed only by permission .                      
(*                                                                     *)
(***********************************************************************)
(*e: copyright header efuns *)
open Efuns

(* Note that there are also globals in other modules: 
 *  - Action.actions, 
 *  - Hook.start_hooks
 *  - Top_window.in_start_macro, 
 *  - ... 
 *)

(*s: global [[Efuns.global_editor]] *)
let global_editor = ref None
(*e: global [[Efuns.global_editor]] *)
s : function [ [ Efuns.editor ] ]
let editor () =
  match !global_editor with
  | None -> failwith "no global editor defined"
  | Some x -> x
e : function [ [ Efuns.editor ] ]

(*s: function [[Efuns.with_lock]] *)
let with_lock f =
  let edt = editor () in
  Mutex.lock edt.edt_mutex;
  Common.finalize f (fun () -> Mutex.unlock edt.edt_mutex)
(*e: function [[Efuns.with_lock]] *)

(*************************************************************************)
(*      Initialization      *)
(*************************************************************************)
  
(* Les variables importantes dans le reste du programme. *)
open Options

(*s: constant [[Efuns.check]] *)
let check = ref false
(*e: constant [[Efuns.check]] *)

s : constants [ [ Efuns.debug_xxx ] ]
let debug = ref false
let debug_graphics = ref false
let debug_display = ref false
let debug_init = ref false
e : constants [ [ Efuns.debug_xxx ] ]

(*s: constant [[Efuns.load_path]] *)
let load_path = define_option ["efuns_path"] 
  "<load_path> is the path where modules (.cmo and .cma) can be found
  for dynamic linking." path_option []
(*e: constant [[Efuns.load_path]] *)

(*s: constant [[Efuns.path]] *)
Dyneval.load_path
(*e: constant [[Efuns.path]] *)
  
(*s: constant [[Efuns.efuns_path]] *)
let efuns_path = [ 
      (Filename.concat Utils.homedir ".efuns") ;

       Version.efuns_lib ; 
       Version.installdir ; 
       Version.ocamllib 

      Version.efuns_lib; 
      Version.installdir; 
      Version.ocamllib
*)
  ]
(*e: constant [[Efuns.efuns_path]] *)
  
s : toplevel [ [  ] ] load path
let _ = 
  path := !!load_path @ efuns_path;
  option_hook load_path (fun _ -> path := !!load_path @ efuns_path)
e : toplevel [ [  ] ] load path

(* used in some major mode *)
(*s: constant [[Efuns.font]] *)
let font = define_option ["font"] "" string_option "Monospace 20"
(*e: constant [[Efuns.font]] *)
  

  for  / server too
(*s: global [[Efuns.displayname]] *)
let displayname = ref ""
(*e: global [[Efuns.displayname]] *)

(*e: core/globals.ml *)

s: core/globals.ml 
s: copyright header efuns 
*********************************************************************
                                                                     
                                                                     
                                                                     
                                                                     
*********************************************************************
e: copyright header efuns 
 Note that there are also globals in other modules: 
 *  - Action.actions, 
 *  - Hook.start_hooks
 *  - Top_window.in_start_macro, 
 *  - ... 
 
s: global [[Efuns.global_editor]] 
e: global [[Efuns.global_editor]] 
s: function [[Efuns.with_lock]] 
e: function [[Efuns.with_lock]] 
***********************************************************************
      Initialization      
***********************************************************************
 Les variables importantes dans le reste du programme. 
s: constant [[Efuns.check]] 
e: constant [[Efuns.check]] 
s: constant [[Efuns.load_path]] 
e: constant [[Efuns.load_path]] 
s: constant [[Efuns.path]] 
e: constant [[Efuns.path]] 
s: constant [[Efuns.efuns_path]] 
e: constant [[Efuns.efuns_path]] 
 used in some major mode 
s: constant [[Efuns.font]] 
e: constant [[Efuns.font]] 
s: global [[Efuns.displayname]] 
e: global [[Efuns.displayname]] 
e: core/globals.ml 
                                                                 
        Fabrice Le Fessant , projet Para / SOR , INRIA Rocquencourt       
   Copyright 1999 Institut National de Recherche en Informatique et   
   Automatique .   Distributed only by permission .                      
open Efuns


let global_editor = ref None
s : function [ [ Efuns.editor ] ]
let editor () =
  match !global_editor with
  | None -> failwith "no global editor defined"
  | Some x -> x
e : function [ [ Efuns.editor ] ]

let with_lock f =
  let edt = editor () in
  Mutex.lock edt.edt_mutex;
  Common.finalize f (fun () -> Mutex.unlock edt.edt_mutex)

  
open Options

let check = ref false

s : constants [ [ Efuns.debug_xxx ] ]
let debug = ref false
let debug_graphics = ref false
let debug_display = ref false
let debug_init = ref false
e : constants [ [ Efuns.debug_xxx ] ]

let load_path = define_option ["efuns_path"] 
  "<load_path> is the path where modules (.cmo and .cma) can be found
  for dynamic linking." path_option []

Dyneval.load_path
  
let efuns_path = [ 
      (Filename.concat Utils.homedir ".efuns") ;

       Version.efuns_lib ; 
       Version.installdir ; 
       Version.ocamllib 

      Version.efuns_lib; 
      Version.installdir; 
      Version.ocamllib
*)
  ]
  
s : toplevel [ [  ] ] load path
let _ = 
  path := !!load_path @ efuns_path;
  option_hook load_path (fun _ -> path := !!load_path @ efuns_path)
e : toplevel [ [  ] ] load path

let font = define_option ["font"] "" string_option "Monospace 20"
  

  for  / server too
let displayname = ref ""

