6 ((not (memq 'font-lock-type-face (face-list)))
7 ; make the necessary faces
9 (set-face-foreground 'Firebrick "Firebrick")
10 (make-face 'RosyBrown)
11 (set-face-foreground 'RosyBrown "RosyBrown")
13 (set-face-foreground 'Purple "Purple")
14 (make-face 'MidnightBlue)
15 (set-face-foreground 'MidnightBlue "MidnightBlue")
16 (make-face 'DarkGoldenRod)
17 (set-face-foreground 'DarkGoldenRod "DarkGoldenRod")
18 (make-face 'DarkOliveGreen)
19 (set-face-foreground 'DarkOliveGreen "DarkOliveGreen4")
20 (make-face 'CadetBlue)
21 (set-face-foreground 'CadetBlue "CadetBlue")
22 ; assign them as standard faces
23 (setq font-lock-comment-face 'Firebrick)
24 (setq font-lock-string-face 'RosyBrown)
25 (setq font-lock-keyword-face 'Purple)
26 (setq font-lock-function-name-face 'MidnightBlue)
27 (setq font-lock-variable-name-face 'DarkGoldenRod)
28 (setq font-lock-type-face 'DarkOliveGreen)
29 (setq font-lock-reference-face 'CadetBlue)))
30 ; extra faces for documention
32 (set-face-foreground 'Stop "White")
33 (set-face-background 'Stop "Red")
35 (set-face-foreground 'Doc "Red")
36 (setq font-lock-stop-face 'Stop)
37 (setq font-lock-doccomment-face 'Doc)
40 ; The same definition is in caml.el:
41 ; we don't know in which order they will be loaded.
42 (defvar caml-quote-char "'"
43 "*Quote for character constants. \"'\" for Objective Caml, \"`\" for Caml-Light.")
45 (defconst caml-font-lock-keywords
47 ;stop special comments
48 '("\\(^\\|[^\"]\\)\\((\\*\\*/\\*\\*)\\)"
49 2 font-lock-stop-face)
51 '("\\(^\\|[^\"]\\)\\((\\*\\*[^*]*\\([^)*][^*]*\\*+\\)*)\\)"
52 2 font-lock-doccomment-face)
54 '("\\(^\\|[^\"]\\)\\((\\*[^*]*\\*+\\([^)*][^*]*\\*+\\)*)\\)"
55 2 font-lock-comment-face)
57 (cons (concat caml-quote-char "\\(\\\\\\([ntbr" caml-quote-char "\\]\\|"
58 "[0-9][0-9][0-9]\\)\\|.\\)" caml-quote-char
59 "\\|\"[^\"\\]*\\(\\\\\\(.\\|\n\\)[^\"\\]*\\)*\"")
60 'font-lock-string-face)
61 ;modules and constructors
62 '("`?\\<[A-Z][A-Za-z0-9_']*\\>" . font-lock-function-name-face)
65 "\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
66 "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
67 "\\|in\\(herit\\|itializer\\)?\\|let"
68 "\\|m\\(ethod\\|utable\\|odule\\)"
69 "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
70 "\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
73 '("\\<\\(begin\\|end\\|object\\|s\\(ig\\|truct\\)\\)\\>"
74 . font-lock-keyword-face)
77 "\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|i\\(f\\|gnore\\)"
78 "\\|lazy\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
79 "\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\)\\>"
81 'font-lock-reference-face)
82 '("\\<raise\\>" . font-lock-comment-face)
84 '("\\(\\([~?]\\|\\<\\)[a-z][a-zA-Z0-9_']*:\\)[^:=]" 1
85 font-lock-variable-name-face)
86 '("\\<\\(assert\\|open\\|include\\)\\>\\|[~?][ (]*[a-z][a-zA-Z0-9_']*"
87 . font-lock-variable-name-face)))
89 (defconst inferior-caml-font-lock-keywords
93 '("^[#-]" . font-lock-comment-face))
94 caml-font-lock-keywords))
96 ;; font-lock commands are similar for caml-mode and inferior-caml-mode
100 ((fboundp 'global-font-lock-mode)
101 (make-local-variable 'font-lock-defaults)
102 (setq font-lock-defaults
103 '(caml-font-lock-keywords nil nil ((?' . "w") (?_ . "w")))))
105 (setq font-lock-keywords caml-font-lock-keywords)))
106 (make-local-variable 'font-lock-keywords-only)
107 (setq font-lock-keywords-only t)
110 (defun inferior-caml-mode-font-hook ()
112 ((fboundp 'global-font-lock-mode)
113 (make-local-variable 'font-lock-defaults)
114 (setq font-lock-defaults
115 '(inferior-caml-font-lock-keywords
116 nil nil ((?' . "w") (?_ . "w")))))
118 (setq font-lock-keywords inferior-caml-font-lock-keywords)))
119 (make-local-variable 'font-lock-keywords-only)
120 (setq font-lock-keywords-only t)
123 (add-hook 'inferior-caml-mode-hooks 'inferior-caml-mode-font-hook)