aboutsummaryrefslogtreecommitdiffhomepage
path: root/phox/phox-outline.el
blob: 7ee2710fa2178fc06e944fc20dff66aea871616a (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
;;--------------------------------------------------------------------------;;
;;--------------------------------------------------------------------------;;
;;                      PARAMÉTRAGE du MODE outline
;;--------------------------------------------------------------------------;;

(require 'outline)

(declare-function phox-lang-absurd "nofile")
(declare-function phox-lang-suppress "nofile")
(declare-function phox-lang-instance "nofile")
(declare-function phox-lang-open-instance "nofile")
(declare-function phox-lang-opendef "nofile")
(declare-function phox-lang-unlock "nofile")
(declare-function phox-lang-lock "nofile")
(declare-function phox-lang-prove "nofile")
(declare-function phox-lang-let "nofile")


(defconst phox-outline-title-regexp "\\((\\*[ \t\n]*title =\\)")
(defconst phox-outline-section-regexp "\\((\\*\\*+\\)")
(defconst phox-outline-save-regexp "\\((\\*#\\)")
(defconst
 phox-outline-theo-regexp
 "\\((\\*lem\\)\\|\\((\\*prop\\)\\|\\((\\*fact\\)\\|\\((\\*theo\\)\\|\\((\\*def\\)\\|\\((\\*cst\\)")
(defconst
 phox-outline-theo2-regexp
 "\\(lem\\)\\|\\(prop\\)\\|\\(fact\\)\\|\\(theo\\)\\|\\(def\\)\\|\\(cst\\)\\|\\(claim\\)\\|\\(new_\\)")

(defconst
  phox-outline-regexp
  (concat
   phox-outline-title-regexp "\\|"
   phox-outline-section-regexp "\\|"
   phox-outline-save-regexp "\\|"
   phox-outline-theo-regexp "\\|"
   phox-outline-theo2-regexp))

(defconst phox-outline-heading-end-regexp "\\(\\*)[ \t]*\n\\)\\|\\(\\.[ \t]*\n\\)")

;;(if phox-outline
;;    (add-hook 'phox-mode-hook (lambda () (outline-minor-mode 1)))
;;  )

(defun phox-outline-level()
  "Find the level of current outline heading in some PhoX libraries."
  (let ((retour 0))
    (save-excursion
      (cond ((looking-at phox-outline-title-regexp) 1)
	    ((looking-at phox-outline-section-regexp)
	     (min 6 (- (match-end 0) (match-beginning 0)))) ; valeur maxi 6
	    ((looking-at phox-outline-theo-regexp) 7)
	    ((looking-at  (concat phox-outline-save-regexp "\\|"
				 phox-outline-theo2-regexp )
			 ) 8)
	    )
      )))

(defun phox-setup-outline ()
  "Set up local variable for outline mode"
  (make-local-variable 'outline-heading-end-regexp)
  (setq outline-heading-end-regexp phox-outline-heading-end-regexp)
  (make-local-variable 'outline-regexp)
  (setq outline-regexp phox-outline-regexp)
  (make-local-variable 'outline-level)
  (setq outline-level 'phox-outline-level)
  (outline-minor-mode 1)
)

(provide 'phox-outline)