Debian Codegraph @

toplevel/coqrc.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 let ( / ) s1 s2 = Filename.concat s1 s2
12
13 (* Loading of the resource file.
14 rcfile is either $XDG_CONFIG_HOME/.coqrc.VERSION, or $XDG_CONFIG_HOME/.coqrc if the first one
15 does not exist. *)
16
17 let rcdefaultname = "coqrc"
18
19 let load_rcfile ~rcfile ~state =
20 try
21 match rcfile with
22 | Some rcfile ->
23 if CUnix.file_readable_p rcfile then
24 Vernac.load_vernac ~echo:false ~check:true ~state rcfile
25 else raise (Sys_error ("Cannot read rcfile: "^ rcfile))
26 | None ->
27 try
28 let warn x = Feedback.msg_warning (Pp.str x) in
29 let inferedrc = List.find CUnix.file_readable_p [
30 Envars.xdg_config_home warn / rcdefaultname^"."^Coq_config.version;
31 Envars.xdg_config_home warn / rcdefaultname;
32 Envars.home ~warn / "."^rcdefaultname^"."^Coq_config.version;
33 Envars.home ~warn / "."^rcdefaultname
34 ] in
35 Vernac.load_vernac ~echo:false ~check:true ~state inferedrc
36 with Not_found -> state
37 (*
38 Flags.if_verbose
39 mSGNL (str ("No coqrc or coqrc."^Coq_config.version^
40 " found. Skipping rcfile loading."))
41 *)
42 with reraise ->
43 let reraise = Exninfo.capture reraise in
44 let () = Feedback.msg_info (Pp.str"Load of rcfile failed.") in
45 Exninfo.iraise reraise