summaryrefslogtreecommitdiff
path: root/emacs/caml-font.el
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1997-02-23 16:23:00 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1997-02-23 16:23:00 +0000
commit84458b8d7f7534bac46278d914c49d6cc5747c17 (patch)
treee24fc9e0ae63b7e03713f7fc48c2b83781da47cc /emacs/caml-font.el
parenta4eea9ac4562aef280b7511671adbf9b604b2bd7 (diff)
downloadocaml-84458b8d7f7534bac46278d914c49d6cc5747c17.tar.gz
Mode OCaml Garrigue/Zimmerman
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1286 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'emacs/caml-font.el')
-rw-r--r--emacs/caml-font.el100
1 files changed, 100 insertions, 0 deletions
diff --git a/emacs/caml-font.el b/emacs/caml-font.el
new file mode 100644
index 0000000000..a1b959d030
--- /dev/null
+++ b/emacs/caml-font.el
@@ -0,0 +1,100 @@
+;; useful colors
+
+; I don't know exactly when font-lock turned color...
+
+(cond
+ ((and (x-display-color-p)
+ (not (string< "19.30" emacs-version)))
+ (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)
+ (set-face-foreground 'DarkOliveGreen "DarkOliveGreen3")
+ (make-face 'CadetBlue)
+ (set-face-foreground 'CadetBlue "CadetBlue")))
+
+(cond
+ ((and (x-display-color-p)
+ (not (string< "19.30" emacs-version)))
+ (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)
+ '("\\<\\(open\\|include\\)\\>\\|[?]?\\<:[A-Za-z][A-Za-z0-9_']*\\>"
+ . 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
+ "\\<\\(and\\|as\\|c\\(onstraint\\|losed\\)"
+ "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
+ "\\|in\\(herit\\)?\\|let\\|m\\(ethod\\|utable\\|odule\\)"
+ "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
+ "\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
+ 'font-lock-type-face)
+;blocking
+ '("\\(\\<\\|:\\)\\(begin\\|class\\|end\\|s\\(ig\\|truct\\)\\)\\>"
+ 2 font-lock-keyword-face)
+;control
+ (cons (concat
+ "\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|if"
+ "\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
+ "\\|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 ()
+ (setq font-lock-keywords caml-font-lock-keywords)
+ (setq font-lock-no-comments t)
+ (font-lock-mode 1)))
+
+(setq inferior-caml-mode-hooks
+ '(lambda ()
+ (setq font-lock-keywords inferior-caml-font-lock-keywords)
+ (setq font-lock-no-comments t)
+ (font-lock-mode 1)))
+
+(provide 'caml-font)