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
31 (make-face 'font-lock-stop-face)
32 (set-face-foreground 'font-lock-stop-face "White")
33 (set-face-background 'font-lock-stop-face "Red")
34 (make-face 'font-lock-doccomment-face)
35 (set-face-foreground 'font-lock-doccomment-face "Red")
38 ; The same definition is in caml.el:
39 ; we don't know in which order they will be loaded.
40 (defvar caml-quote-char "'"
41 "*Quote for character constants. \"'\" for Objective Caml, \"`\" for Caml-Light.")
43 (defconst caml-font-lock-keywords
45 ;stop special comments
46 '("\\(^\\|[^\"]\\)\\((\\*\\*/\\*\\*)\\)"
47 2 font-lock-stop-face)
49 '("\\(^\\|[^\"]\\)\\((\\*\\*[^*]*\\([^)*][^*]*\\*+\\)*)\\)"
50 2 font-lock-doccomment-face)
52 '("\\(^\\|[^\"]\\)\\((\\*[^*]*\\*+\\([^)*][^*]*\\*+\\)*)\\)"
53 2 font-lock-comment-face)
55 (cons (concat caml-quote-char "\\(\\\\\\([ntbr" caml-quote-char "\\]\\|"
56 "[0-9][0-9][0-9]\\)\\|.\\)" caml-quote-char
57 "\\|\"[^\"\\]*\\(\\\\\\(.\\|\n\\)[^\"\\]*\\)*\"")
58 'font-lock-string-face)
59 ;modules and constructors
60 '("`?\\<[A-Z][A-Za-z0-9_']*\\>" . font-lock-function-name-face)
63 "\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
64 "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
65 "\\|in\\(herit\\|itializer\\)?\\|let"
66 "\\|m\\(ethod\\|utable\\|odule\\)"
67 "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
68 "\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
71 '("\\<\\(begin\\|end\\|object\\|s\\(ig\\|truct\\)\\)\\>"
72 . font-lock-keyword-face)
75 "\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|i\\(f\\|gnore\\)"
76 "\\|lazy\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
77 "\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\)\\>"
79 'font-lock-reference-face)
80 '("\\<raise\\>" . font-lock-comment-face)
82 '("\\(\\([~?]\\|\\<\\)[a-z][a-zA-Z0-9_']*:\\)[^:=]" 1
83 font-lock-variable-name-face)
84 '("\\<\\(assert\\|open\\|include\\)\\>\\|[~?][ (]*[a-z][a-zA-Z0-9_']*"
85 . font-lock-variable-name-face)))
87 (defconst inferior-caml-font-lock-keywords
91 '("^[#-]" . font-lock-comment-face))
92 caml-font-lock-keywords))
94 ;; font-lock commands are similar for caml-mode and inferior-caml-mode
98 ((fboundp 'global-font-lock-mode)
99 (make-local-variable 'font-lock-defaults)
100 (setq font-lock-defaults
101 '(caml-font-lock-keywords nil nil ((?' . "w") (?_ . "w")))))
103 (setq font-lock-keywords caml-font-lock-keywords)))
104 (make-local-variable 'font-lock-keywords-only)
105 (setq font-lock-keywords-only t)
108 (defun inferior-caml-mode-font-hook ()
110 ((fboundp 'global-font-lock-mode)
111 (make-local-variable 'font-lock-defaults)
112 (setq font-lock-defaults
113 '(inferior-caml-font-lock-keywords
114 nil nil ((?' . "w") (?_ . "w")))))
116 (setq font-lock-keywords inferior-caml-font-lock-keywords)))
117 (make-local-variable 'font-lock-keywords-only)
118 (setq font-lock-keywords-only t)
121 (add-hook 'inferior-caml-mode-hooks 'inferior-caml-mode-font-hook)