1997-02-23 08:23:00 -08:00
|
|
|
;; useful colors
|
|
|
|
|
|
|
|
(cond
|
|
|
|
((and (x-display-color-p)
|
1997-07-17 02:46:54 -07:00
|
|
|
(not (memq 'font-lock-type-face (face-list))))
|
|
|
|
; make the necessary faces
|
1997-02-23 08:23:00 -08:00
|
|
|
(make-face 'Firebrick)
|
|
|
|
(set-face-foreground 'Firebrick "Firebrick")
|
|
|
|
(make-face 'RosyBrown)
|
|
|
|
(set-face-foreground 'RosyBrown "RosyBrown")
|
|
|
|
(make-face 'Purple)
|
|
|
|
(set-face-foreground 'Purple "Purple")
|
|
|
|
(make-face 'MidnightBlue)
|
|
|
|
(set-face-foreground 'MidnightBlue "MidnightBlue")
|
|
|
|
(make-face 'DarkGoldenRod)
|
|
|
|
(set-face-foreground 'DarkGoldenRod "DarkGoldenRod")
|
|
|
|
(make-face 'DarkOliveGreen)
|
1997-07-17 02:46:54 -07:00
|
|
|
(set-face-foreground 'DarkOliveGreen "DarkOliveGreen4")
|
1997-02-23 08:23:00 -08:00
|
|
|
(make-face 'CadetBlue)
|
1997-07-17 02:46:54 -07:00
|
|
|
(set-face-foreground 'CadetBlue "CadetBlue")
|
|
|
|
; assign them as standard faces
|
1997-02-23 08:23:00 -08:00
|
|
|
(setq font-lock-comment-face 'Firebrick)
|
|
|
|
(setq font-lock-string-face 'RosyBrown)
|
|
|
|
(setq font-lock-keyword-face 'Purple)
|
|
|
|
(setq font-lock-function-name-face 'MidnightBlue)
|
|
|
|
(setq font-lock-variable-name-face 'DarkGoldenRod)
|
|
|
|
(setq font-lock-type-face 'DarkOliveGreen)
|
|
|
|
(setq font-lock-reference-face 'CadetBlue)))
|
|
|
|
|
|
|
|
; The same definition is in caml.el:
|
|
|
|
; we don't know in which order they will be loaded.
|
|
|
|
(defvar caml-quote-char "'"
|
|
|
|
"*Quote for character constants. \"'\" for Objective Caml, \"`\" for Caml-Light.")
|
|
|
|
|
|
|
|
(defconst caml-font-lock-keywords
|
|
|
|
(list
|
|
|
|
;comments
|
|
|
|
'("\\(^\\|[^\"]\\)\\((\\*[^*]*\\*+\\([^)*][^*]*\\*+\\)*)\\)"
|
|
|
|
2 font-lock-comment-face)
|
|
|
|
;character literals
|
|
|
|
(cons (concat caml-quote-char "\\(\\\\\\([ntbr" caml-quote-char "\\]\\|"
|
|
|
|
"[0-9][0-9][0-9]\\)\\|.\\)" caml-quote-char
|
|
|
|
"\\|\"[^\"\\]*\\(\\\\\\(.\\|\n\\)[^\"\\]*\\)*\"")
|
|
|
|
'font-lock-string-face)
|
|
|
|
;labels (and open)
|
|
|
|
'("\\([?]?\\<[A-Za-z][A-Za-z0-9_']*:\\)\\([^:=]\\|\\'\\|$\\)" 1
|
|
|
|
font-lock-variable-name-face)
|
1998-10-14 00:36:51 -07:00
|
|
|
'("\\<\\(assert\\|open\\|include\\)\\>\\|[?]?\\<:[A-Za-z][A-Za-z0-9_']*\\>"
|
1997-02-23 08:23:00 -08:00
|
|
|
. font-lock-variable-name-face)
|
|
|
|
;modules and constructors
|
|
|
|
'("\\(\\<\\|:\\)\\([A-Z][A-Za-z0-9_']*\\)\\>"
|
|
|
|
2 font-lock-function-name-face)
|
|
|
|
'("`[A-Za-z][A-Za-z0-9_']*\\>" . font-lock-function-name-face)
|
|
|
|
;definition
|
|
|
|
(cons (concat
|
1998-10-14 00:36:51 -07:00
|
|
|
"\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
|
1997-02-23 08:23:00 -08:00
|
|
|
"\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
|
1998-10-14 00:36:51 -07:00
|
|
|
"\\|in\\(herit\\|itializer\\)?\\|let"
|
|
|
|
"\\|m\\(ethod\\|utable\\|odule\\)"
|
1997-02-23 08:23:00 -08:00
|
|
|
"\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
|
|
|
|
"\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
|
|
|
|
'font-lock-type-face)
|
|
|
|
;blocking
|
1998-10-14 00:36:51 -07:00
|
|
|
'("\\(\\<\\|:\\)\\(begin\\|end\\|object\\|s\\(ig\\|truct\\)\\)\\>"
|
1997-02-23 08:23:00 -08:00
|
|
|
2 font-lock-keyword-face)
|
|
|
|
;control
|
|
|
|
(cons (concat
|
|
|
|
"\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|if"
|
1998-10-14 00:36:51 -07:00
|
|
|
"\\|lazy\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
|
1997-02-23 08:23:00 -08:00
|
|
|
"\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\)\\>"
|
|
|
|
"\\|\|\\|->\\|&\\|#")
|
|
|
|
'font-lock-reference-face)
|
|
|
|
'("\\<raise\\>" . font-lock-comment-face)))
|
|
|
|
|
|
|
|
(defconst inferior-caml-font-lock-keywords
|
|
|
|
(append
|
|
|
|
(list
|
|
|
|
;inferior
|
|
|
|
'("^[#-]" . font-lock-comment-face)
|
|
|
|
;labels
|
|
|
|
'("[? \t]:[A-Za-z][A-Za-z0-9_']*\\>" . font-lock-variable-name-face))
|
|
|
|
caml-font-lock-keywords))
|
|
|
|
|
|
|
|
;; font-lock commands are similar for caml-mode and inferior-caml-mode
|
|
|
|
(setq caml-mode-hook
|
|
|
|
'(lambda ()
|
1997-07-17 02:46:54 -07:00
|
|
|
(cond
|
|
|
|
((fboundp 'global-font-lock-mode)
|
|
|
|
(make-local-variable 'font-lock-defaults)
|
|
|
|
(setq font-lock-defaults
|
|
|
|
'(caml-font-lock-keywords nil nil ((?' . "w") (?_ . "w")))))
|
|
|
|
(t
|
|
|
|
(setq font-lock-keywords caml-font-lock-keywords)))
|
1999-01-31 17:55:27 -08:00
|
|
|
(make-local-variable 'font-lock-keywords-only)
|
1998-10-14 00:36:51 -07:00
|
|
|
(setq font-lock-keywords-only t)
|
1997-02-23 08:23:00 -08:00
|
|
|
(font-lock-mode 1)))
|
|
|
|
|
|
|
|
(setq inferior-caml-mode-hooks
|
|
|
|
'(lambda ()
|
1997-07-17 02:46:54 -07:00
|
|
|
(cond
|
|
|
|
((fboundp 'global-font-lock-mode)
|
|
|
|
(make-local-variable 'font-lock-defaults)
|
|
|
|
(setq font-lock-defaults
|
|
|
|
'(inferior-caml-font-lock-keywords
|
|
|
|
nil nil ((?' . "w") (?_ . "w")))))
|
|
|
|
(t
|
|
|
|
(setq font-lock-keywords inferior-caml-font-lock-keywords)))
|
1998-12-16 01:32:04 -08:00
|
|
|
(make-local-variable 'font-lock-keywords-only)
|
1998-10-14 00:36:51 -07:00
|
|
|
(setq font-lock-keywords-only t)
|
1997-02-23 08:23:00 -08:00
|
|
|
(font-lock-mode 1)))
|
|
|
|
|
|
|
|
(provide 'caml-font)
|