aboutsummaryrefslogtreecommitdiffhomepage
path: root/generic/proof-site.el
blob: eda5261c5b752879a99d24fd1b1639fa81ac9248 (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;; proof-site.el -- Configuration for site and choice of provers.
;;
;; Copyright (C) 1998 LFCS Edinburgh. 
;; Authors: David Aspinall
;; Maintainer:  Proof General maintainer <proofgen@dcs.ed.ac.uk>
;;
;; $Id$
;;

(or (featurep 'custom)
    ;; Quick hack to support defcustom for Emacs 19
    ;; FIXME da: Remove this soon.
    ;; Customize works fine with Emacs 20.2
    (defmacro defcustom (sym val doc &rest args)
      (defvar sym val doc))
    (defmacro group (sym mems doc &rest args)))


(defgroup proof nil
  "Customization of Proof General."
  :group 'external
  :group 'processes)


;; This customization group gathers together
;; the internals of Proof General which control
;; configuration to different proof assistants.
;; This is for development purposes rather than
;; user-level customization, so this group does
;; not belong to 'proof (or any other group).
(defgroup proof-internal nil
  "Customization of Proof General internals.")


;; Master table of supported assistants.
(defcustom proof-internal-assistant-table
  '((isa	"Isabelle"	"\\.ML$\\|\\.thy$")
    (lego	"LEGO"		"\\.l$")
    (coq	"Coq"		"\\.v$"))
  "Proof General's table of supported proof assistants.
Extend this table to add a new proof assistant.
Each entry is a list of the form

    (SYMBOL NAME AUTOMODE-REGEXP)

The NAME is a string, naming the proof assistant.
The SYMBOL is used to form the name of the mode for the
assistant, `SYMBOL-mode`, run when files with AUTOMODE-REGEXP
are visited.  SYMBOL is also used to form the name of the
directory and elisp file for the mode, which will be
 
    <proof-directory-home>/SYMBOL/SYMBOL.el

where `<proof-directory-home>/' is the value of the
variable proof-directory-home."
  :type '(repeat (list symbol string string))
  :group 'proof-internal)


;; Directories

(defcustom proof-internal-home-directory
  ;; FIXME: make sure compiling does not evaluate next expression.
  (or (getenv "PROOFGENERAL_HOME") 
      (let ((curdir 
	     (or
	      (and load-in-progress (file-name-directory load-file-name))
	      (file-name-directory (buffer-file-name)))))
	(file-name-directory (substring curdir 0 -1))))
  "*Directory where Proof General is installed. Ends with slash.
Default value taken from environment variable PROOFGENERAL_HOME if set, 
otherwise based on where the file proof-site was loaded from.
You can use customize to set this variable."
  :type 'directory
  :group 'proof-internal)

(defcustom proof-internal-images-directory
  (concat proof-internal-home-directory "images/")
    "*Where Proof General image files are installed. Ends with slash."
  :type 'directory
  :group 'proof-internal)

(defcustom proof-internal-info-directory
  (concat proof-internal-home-directory "doc/")
  "*Where Proof General Info files are installed."
  :type 'directory
  :group 'proof-internal)

;; Add the info directory to the end of Emacs Info path 
;; if need be. 
(or (member proof-internal-info-directory Info-default-directory-list)
    (setq Info-default-directory-list
	  (append 
	   Info-default-directory-list 
	   (list proof-internal-info-directory))))

;; Might be nicer to have a boolean for each supported assistant.
(defcustom proof-assistants
  (mapcar (lambda (astnt) (car astnt))
	  proof-internal-assistant-table)
  (concat
   "*Choice of proof assitants to use with Proof General.
A list of symbols chosen from: " 
   (apply 'concat (mapcar (lambda (astnt) 
			    (concat "'" (symbol-name (car astnt)) " "))
			  proof-internal-assistant-table)) 
".\nEach proof assistant defines its own instance of Proof General,
providing session control, script management, etc.  Proof General
will be started automatically for the assistants chosen here.
To avoid accidently invoking a proof assistant you don't have,
only select the proof assistants you (or your site) may need.
NOTE: to change proof assistant, you must start a new Emacs session.")
  :type (cons 'set 
	      (mapcar (lambda (astnt)
			(list 'const ':tag (car (cdr astnt)) (car astnt)))
		      proof-internal-assistant-table))
  :group 'proof)

;; Extend load path for the generic files.
(let ((proof-lisp-path
       (concat proof-internal-home-directory "generic/")))
  (or (member proof-lisp-path load-path)
      (setq load-path
	    (cons proof-lisp-path load-path))))

;; Now add auto-loads and load-path elements to support the 
;; proof assistants selected, and define a stub 
(let ((assistants proof-assistants) proof-assistant)
  (while assistants
    (let*  
	((proof-assistant (car assistants))
	 (nameregexp 
	  (or 
	   (cdr-safe 
	    (assoc proof-assistant
		   proof-internal-assistant-table))
	   (error "proof-site: symbol " (symbol-name proof-assistant) 
		  "is not in proof-internal-assistant-table")))
	 (assistant-name (car nameregexp))
	 (regexp	 (car (cdr nameregexp)))
	 (sname		 (symbol-name proof-assistant))
	 ;; NB: File name for each prover is the same as its symbol name!
	 (elisp-file   sname)
	 ;; NB: Dir name for each prover is the same as its symbol name!
	 (elisp-dir    sname)
	 ;; NB: Mode name for each prover is <symbol name>-mode!
	 (proofgen-mode  (intern (concat sname "-mode")))
	 ;; NB: Customization group for each prover is its l.c.'d name!
	 (cusgrp	 (intern (downcase assistant-name)))

	 ;; Stub to do some automatic initialization and load
	 ;; the specific code.
	 (mode-stub
	   `(lambda ()
	      ,(concat
		 "Major mode for editing scripts for proof assistant "
		 assistant-name
		 ".\nThis is a stub which loads the real function.")
	      (interactive)
	      ;; Make a customization group for this assistant
	      (defgroup ,cusgrp nil
		,(concat "Customization of " assistant-name
			 " specific settings for Proof General.")
		:group 'proof)
	      ;; Set the proof-assistant configuration variable
	      (setq proof-assistant ,assistant-name)
	      ;; Extend the load path, load the real mode and invoke it.
	      (setq load-path 
		    (cons (concat proof-internal-home-directory ,elisp-dir "/")
			  load-path))
	      (load-library ,elisp-file)
	      (,proofgen-mode))))

      (setq auto-mode-alist 
	    (cons (cons regexp proofgen-mode) auto-mode-alist))

      (fset proofgen-mode mode-stub)
      
      (setq assistants (cdr assistants))
      )))

;; WARNING: do not edit below here 
;; (the next constant is set automatically)
(defconst proof-version
 "Proof General, Version 2.0-pre980910 released by da,tms. Email proofgen@dcs.ed.ac.uk."
 "Version string for Proof General.")

(provide 'proof-site)