blob: aa6e7d40ab87e4e712c9dcfdb1a562f3728ba2e9 (
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
|
;; proof-maths-menu.el Support for maths menu mode package
;;
;; Copyright (C) 2007 LFCS Edinburgh / David Aspinall
;; Author: David Aspinall <David.Aspinall@ed.ac.uk>
;; License: GPL (GNU GENERAL PUBLIC LICENSE)
;;
;;
;; With thanks to Dave Love for the original maths menu code,
;; provided at http://www.loveshack.ukfsn.org/emacs/
;;
;; $Id$
;;
;; =================================================================
;;
;; NB: maths-menu is bundled with Proof General in lib/, and PG will select
;; it's own version before any other version on the Emacs load path.
;; If you want to override this, simply load your version before
;; starting Emacs, with (require 'maths-menu).
;;
(eval-when-compile
(require 'proof-utils) ; for proof-ass, proof-eval-when-ready-for-assistant
(require 'cl))
(eval-when (compile)
(require 'maths-menu)) ; it's loaded dynamically at runtime
;;;###autoload
(defun proof-maths-menu-support-available ()
"A test to see whether maths-menu support is available."
(and
(not (featurep 'xemacs)) ;; not XEmacs compatible
(or (featurep 'maths-menu)
;; *should* always succeed unless bundled version broken
(proof-try-require 'maths-menu))
;; Load any optional prover-specific config in <foo>-maths-menu.el
(or (proof-try-require (proof-ass-sym maths-menu)) t)))
(defun proof-maths-menu-set-global (flag)
"Set global status of maths-menu mode for PG buffers to be FLAG.
Turn on/off menu in all script buffers and ensure new buffers follow suit."
(let ((hook (proof-ass-sym mode-hook)))
(if flag
(add-hook hook 'maths-menu-mode)
(remove-hook hook 'maths-menu-mode))
(proof-map-buffers
(proof-buffers-in-mode proof-mode-for-script)
(maths-menu-mode (if flag 1 0)))))
;;;###autoload
(defun proof-maths-menu-enable ()
"Turn on or off maths-menu mode in Proof General script buffer.
This invokes `maths-menu-mode' to toggle the setting for the current
buffer, and then sets PG's option for default to match.
Also we arrange to have maths menu mode turn itself on automatically
in future if we have just activated it for this buffer."
(interactive)
(if (proof-maths-menu-support-available) ;; will load maths-menu-mode
(proof-maths-menu-set-global (not maths-menu-mode))))
;;
;; On start up, adjust automode according to user setting
;;
(proof-eval-when-ready-for-assistant
(if (and (proof-ass maths-menu-enable)
(proof-maths-menu-support-available))
(proof-maths-menu-set-global t)))
(provide 'proof-maths-menu)
;; End of proof-maths-menu.el
|