commit/ocaml: Jerry James: Define faces the XEmacs way in caml-font.el. See xemacs-patches message

[email protected]
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
1 new commit in ocaml:

https://bitbucket.org/xemacs/ocaml/commits/b485116970ca/
Changeset:   b485116970ca
User:        Jerry James
Date:        2014-06-06 18:29:14
Summary:     Define faces the XEmacs way in caml-font.el.  See xemacs-patches message
<CAHCOHQkGnjCA8uTRwcHZxK9bM9qqO7=AYkrhjjR=UQqErY=SoA@mail.gmail.com>.
Affected #:  3 files

diff -r c4cb09505870daade773d501aa59d4abd04265c5 -r b485116970ca274a9eecfc4fa7e5a4a8d2f30a1d ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-05  Jerry James  <[email protected]>
+
+	* caml-font.el: Define faces the XEmacs way.
+
 2014-05-15  Norbert Koch  <[email protected]>
 
 	* Makefile (VERSION): XEmacs package 0.08 released.

diff -r c4cb09505870daade773d501aa59d4abd04265c5 -r b485116970ca274a9eecfc4fa7e5a4a8d2f30a1d caml-font.el
--- a/caml-font.el
+++ b/caml-font.el
@@ -28,13 +28,11 @@
     (setq font-lock-type-face 'DarkOliveGreen)
     (setq font-lock-reference-face 'CadetBlue)))
   ; extra faces for documention
-  (make-face 'Stop)
-  (set-face-foreground 'Stop "White")
-  (set-face-background 'Stop "Red")
-  (make-face 'Doc)
-  (set-face-foreground 'Doc "Red")
-  (setq font-lock-stop-face 'Stop)
-  (setq font-lock-doccomment-face 'Doc)
+  (make-face 'font-lock-stop-face)
+  (set-face-foreground 'font-lock-stop-face "White")
+  (set-face-background 'font-lock-stop-face "Red")
+  (make-face 'font-lock-doccomment-face)
+  (set-face-foreground 'font-lock-doccomment-face "Red")
 ))
 
 ; The same definition is in caml.el:

diff -r c4cb09505870daade773d501aa59d4abd04265c5 -r b485116970ca274a9eecfc4fa7e5a4a8d2f30a1d caml-font.el.upstream
--- /dev/null
+++ b/caml-font.el.upstream
@@ -0,0 +1,125 @@
+;; useful colors
+
+(cond
+ ((x-display-color-p)
+  (cond
+   ((not (memq 'font-lock-type-face (face-list)))
+    ; make the necessary faces
+    (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 "DarkOliveGreen4")
+    (make-face 'CadetBlue)
+    (set-face-foreground 'CadetBlue "CadetBlue")
+    ; assign them as standard faces
+    (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)))
+  ; extra faces for documention
+  (make-face 'Stop)
+  (set-face-foreground 'Stop "White")
+  (set-face-background 'Stop "Red")
+  (make-face 'Doc)
+  (set-face-foreground 'Doc "Red")
+  (setq font-lock-stop-face 'Stop)
+  (setq font-lock-doccomment-face 'Doc)
+))
+
+; 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
+;stop special comments
+   '("\\(^\\|[^\"]\\)\\((\\*\\*/\\*\\*)\\)"
+     2 font-lock-stop-face)
+;doccomments
+   '("\\(^\\|[^\"]\\)\\((\\*\\*[^*]*\\([^)*][^*]*\\*+\\)*)\\)"
+     2 font-lock-doccomment-face)
+;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)
+;modules and constructors
+   '("`?\\<[A-Z][A-Za-z0-9_']*\\>" . font-lock-function-name-face)
+;definition
+   (cons (concat
+          "\\<\\(a\\(nd\\|s\\)\\|c\\(onstraint\\|lass\\)"
+          "\\|ex\\(ception\\|ternal\\)\\|fun\\(ct\\(ion\\|or\\)\\)?"
+          "\\|in\\(herit\\|itializer\\)?\\|let"
+          "\\|m\\(ethod\\|utable\\|odule\\)"
+          "\\|of\\|p\\(arser\\|rivate\\)\\|rec\\|type"
+          "\\|v\\(al\\(ue\\)?\\|irtual\\)\\)\\>")
+         'font-lock-type-face)
+;blocking
+   '("\\<\\(begin\\|end\\|object\\|s\\(ig\\|truct\\)\\)\\>"
+     . font-lock-keyword-face)
+;control
+   (cons (concat
+          "\\<\\(do\\(ne\\|wnto\\)?\\|else\\|for\\|i\\(f\\|gnore\\)"
+          "\\|lazy\\|match\\|new\\|or\\|t\\(hen\\|o\\|ry\\)"
+          "\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\)\\>"
+          "\\|\|\\|->\\|&\\|#")
+         'font-lock-reference-face)
+   '("\\<raise\\>" . font-lock-comment-face)
+;labels (and open)
+   '("\\(\\([~?]\\|\\<\\)[a-z][a-zA-Z0-9_']*:\\)[^:=]" 1
+     font-lock-variable-name-face)
+   '("\\<\\(assert\\|open\\|include\\)\\>\\|[~?][ (]*[a-z][a-zA-Z0-9_']*"
+     . font-lock-variable-name-face)))
+
+(defconst inferior-caml-font-lock-keywords
+  (append
+   (list
+;inferior
+    '("^[#-]" . font-lock-comment-face))
+   caml-font-lock-keywords))
+
+;; font-lock commands are similar for caml-mode and inferior-caml-mode
+(setq caml-mode-hook
+      '(lambda ()
+         (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)))
+         (make-local-variable 'font-lock-keywords-only)
+         (setq font-lock-keywords-only t)
+         (font-lock-mode 1)))
+
+(defun inferior-caml-mode-font-hook ()
+  (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)))
+  (make-local-variable 'font-lock-keywords-only)
+  (setq font-lock-keywords-only t)
+  (font-lock-mode 1))
+
+(add-hook 'inferior-caml-mode-hooks 'inferior-caml-mode-font-hook)
+
+(provide 'caml-font)

Repository URL: https://bitbucket.org/xemacs/ocaml/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.