use cooper theme -- end of git, I am trying livemesh
[srid.dotfiles.git] / emacs / external / ml / caml-font.el
blob8454aa35049305d250a098e5e55a31e10f136023
1 ;(***********************************************************************)
2 ;(* *)
3 ;(* Objective Caml *)
4 ;(* *)
5 ;(* Jacques Garrigue and Ian T Zimmerman *)
6 ;(* *)
7 ;(* Copyright 1997 Institut National de Recherche en Informatique et *)
8 ;(* en Automatique. All rights reserved. This file is distributed *)
9 ;(* under the terms of the GNU General Public License. *)
10 ;(* *)
11 ;(***********************************************************************)
13 ;(* $Id: caml-font.el,v 1.18.2.1 2004/08/09 16:09:33 doligez Exp $ *)
15 ;; useful colors
17 (cond
18 ((x-display-color-p)
19 (require 'font-lock)
20 (cond
21 ((not (boundp 'font-lock-type-face))
22 ; make the necessary faces
23 (make-face 'Firebrick)
24 (set-face-foreground 'Firebrick "Firebrick")
25 (make-face 'RosyBrown)
26 (set-face-foreground 'RosyBrown "RosyBrown")
27 (make-face 'Purple)
28 (set-face-foreground 'Purple "Purple")
29 (make-face 'MidnightBlue)
30 (set-face-foreground 'MidnightBlue "MidnightBlue")
31 (make-face 'DarkGoldenRod)
32 (set-face-foreground 'DarkGoldenRod "DarkGoldenRod")
33 (make-face 'DarkOliveGreen)
34 (set-face-foreground 'DarkOliveGreen "DarkOliveGreen4")
35 (make-face 'CadetBlue)
36 (set-face-foreground 'CadetBlue "CadetBlue")
37 ; assign them as standard faces
38 (setq font-lock-comment-face 'Firebrick)
39 (setq font-lock-string-face 'RosyBrown)
40 (setq font-lock-keyword-face 'Purple)
41 (setq font-lock-function-name-face 'MidnightBlue)
42 (setq font-lock-variable-name-face 'DarkGoldenRod)
43 (setq font-lock-type-face 'DarkOliveGreen)
44 (setq font-lock-reference-face 'CadetBlue)))
45 ; extra faces for documention
46 (make-face 'Stop)
47 (set-face-foreground 'Stop "White")
48 (set-face-background 'Stop "Red")
49 (make-face 'Doc)
50 (set-face-foreground 'Doc "Red")
51 (setq font-lock-stop-face 'Stop)
52 (setq font-lock-doccomment-face 'Doc)
55 ; The same definition is in caml.el:
56 ; we don't know in which order they will be loaded.
57 (defvar caml-quote-char "'"
58 "*Quote for character constants. \"'\" for Objective Caml, \"`\" for Caml-Light.")
60 (defconst caml-font-lock-keywords
61 (list
62 ;stop special comments
63 '("\\(^\\|[^\"]\\)\\((\\*\\*/\\*\\*)\\)"
64 2 font-lock-stop-face)
65 ;doccomments
66 '("\\(^\\|[^\"]\\)\\((\\*\\*[^*]*\\([^)*][^*]*\\*+\\)*)\\)"
67 2 font-lock-doccomment-face)
68 ;comments
69 '("\\(^\\|[^\"]\\)\\((\\*[^*]*\\*+\\([^)*][^*]*\\*+\\)*)\\)"
70 2 font-lock-comment-face)
71 ;character literals
72 (cons (concat caml-quote-char "\\(\\\\\\([ntbr" caml-quote-char "\\]\\|"
73 "[0-9][0-9][0-9]\\)\\|.\\)" caml-quote-char
74 "\\|\"[^\"\\]*\\(\\\\\\(.\\|\n\\)[^\"\\]*\\)*\"")
75 'font-lock-string-face)
76 ;modules and constructors
77 '("`?\\<[A-Z][A-Za-z0-9_']*\\>" . font-lock-function-name-face)
78 ;definition
79 (cons (concat
80 "\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
81 "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
82 "\\|in\\(herit\\|itializer\\)?\\|let"
83 "\\|m\\(ethod\\|utable\\|odule\\)"
84 "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
85 "\\|v\\(al\\|irtual\\)\\)\\>")
86 'font-lock-type-face)
87 ;blocking
88 '("\\<\\(begin\\|end\\|object\\|s\\(ig\\|truct\\)\\)\\>"
89 . font-lock-keyword-face)
90 ;control
91 (cons (concat
92 "\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|i\\(f\\|gnore\\)"
93 "\\|lazy\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
94 "\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\)\\>"
95 "\\|\|\\|->\\|&\\|#")
96 'font-lock-reference-face)
97 '("\\<raise\\>" . font-lock-comment-face)
98 ;labels (and open)
99 '("\\(\\([~?]\\|\\<\\)[a-z][a-zA-Z0-9_']*:\\)[^:=]" 1
100 font-lock-variable-name-face)
101 '("\\<\\(assert\\|open\\|include\\)\\>\\|[~?][ (]*[a-z][a-zA-Z0-9_']*"
102 . font-lock-variable-name-face)))
104 (defconst inferior-caml-font-lock-keywords
105 (append
106 (list
107 ;inferior
108 '("^[#-]" . font-lock-comment-face))
109 caml-font-lock-keywords))
111 ;; font-lock commands are similar for caml-mode and inferior-caml-mode
112 (add-hook 'caml-mode-hook
113 '(lambda ()
114 (cond
115 ((fboundp 'global-font-lock-mode)
116 (make-local-variable 'font-lock-defaults)
117 (setq font-lock-defaults
118 '(caml-font-lock-keywords nil nil ((?' . "w") (?_ . "w")))))
120 (setq font-lock-keywords caml-font-lock-keywords)))
121 (make-local-variable 'font-lock-keywords-only)
122 (setq font-lock-keywords-only t)
123 (font-lock-mode 1)))
125 (defun inferior-caml-mode-font-hook ()
126 (cond
127 ((fboundp 'global-font-lock-mode)
128 (make-local-variable 'font-lock-defaults)
129 (setq font-lock-defaults
130 '(inferior-caml-font-lock-keywords
131 nil nil ((?' . "w") (?_ . "w")))))
133 (setq font-lock-keywords inferior-caml-font-lock-keywords)))
134 (make-local-variable 'font-lock-keywords-only)
135 (setq font-lock-keywords-only t)
136 (font-lock-mode 1))
138 (add-hook 'inferior-caml-mode-hooks 'inferior-caml-mode-font-hook)
140 (provide 'caml-font)