emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] externals/caml da654aa 179/197: Emacs: Modernise font face defi


From: Stefan Monnier
Subject: [nongnu] externals/caml da654aa 179/197: Emacs: Modernise font face definitions
Date: Sat, 21 Nov 2020 01:20:02 -0500 (EST)

branch: externals/caml
commit da654aaa2d2fc5c63719b3e439acc21f0f0b13c6
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Wilfred Hughes <me@wilfred.me.uk>

    Emacs: Modernise font face definitions
    
    make-face is a low-level primitive function that packages should not
    be calling. Packages should use defface instead, which has existed
    since at least Emacs 21.1 (released 2001).
    
    By using defface, Emacs can find the definition of the face, and it's
    easier to define different colours for light and dark themes. Also fix
    spelling in docstrings.
    
    Also remove fallback code for font-lock-type-face, as this variable
    was created before 2000. Likewise font-lock-preprocessor-face, which
    dates from 2003.
---
 caml-font-old.el | 27 +--------------------------
 caml-font.el     |  5 -----
 caml-types.el    | 40 +++++++++++++++-------------------------
 3 files changed, 16 insertions(+), 56 deletions(-)

diff --git a/caml-font-old.el b/caml-font-old.el
index fb39c22..949ca32 100644
--- a/caml-font-old.el
+++ b/caml-font-old.el
@@ -17,32 +17,7 @@
 (cond
  ((x-display-color-p)
   (require 'font-lock)
-  (cond
-   ((not (boundp 'font-lock-type-face))
-    ; 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 documentation
+  ;; extra faces for documentation
   (make-face 'Stop)
   (set-face-foreground 'Stop "White")
   (set-face-background 'Stop "Red")
diff --git a/caml-font.el b/caml-font.el
index 91c6fce..a282995 100644
--- a/caml-font.el
+++ b/caml-font.el
@@ -30,11 +30,6 @@
     (set-face-foreground 'caml-font-doccomment-face "Red")
     'caml-font-doccomment-face))
 
-(unless (facep 'font-lock-preprocessor-face)
-  (defvar font-lock-preprocessor-face
-    (copy-face 'font-lock-builtin-face
-               'font-lock-preprocessor-face)))
-
 (defconst caml-font-lock-keywords
   `(
 ;modules and constructors
diff --git a/caml-types.el b/caml-types.el
index dc01af6..6d6775a 100644
--- a/caml-types.el
+++ b/caml-types.el
@@ -85,44 +85,34 @@ type call ident")
   (setq caml-types-location-re
         (concat "^" caml-types-position-re " " caml-types-position-re)))
 
+(defface caml-types-expr-face '((t :background "#88FF44"))
+  "Face for highlighting expressions and types")
+
 (defvar caml-types-expr-ovl (make-overlay 1 1))
-(make-face 'caml-types-expr-face)
-(set-face-doc-string 'caml-types-expr-face
-                     "face for hilighting expressions and types")
-(if (not (face-differs-from-default-p 'caml-types-expr-face))
-    (set-face-background 'caml-types-expr-face "#88FF44"))
 (overlay-put caml-types-expr-ovl 'face 'caml-types-expr-face)
 
+(defface caml-types-typed-face '((t :background "#FF8844"))
+  "Face for highlighting typed expressions.")
+
 (defvar caml-types-typed-ovl (make-overlay 1 1))
-(make-face 'caml-types-typed-face)
-(set-face-doc-string 'caml-types-typed-face
-                     "face for hilighting typed expressions")
-(if (not (face-differs-from-default-p 'caml-types-typed-face))
-    (set-face-background 'caml-types-typed-face "#FF8844"))
 (overlay-put caml-types-typed-ovl 'face 'caml-types-typed-face)
 
+(defface caml-types-scope-face '((t :background "#BBFFFF"))
+  "Face for highlighting variable scopes.")
+
 (defvar caml-types-scope-ovl (make-overlay 1 1))
-(make-face 'caml-types-scope-face)
-(set-face-doc-string 'caml-types-scope-face
-                     "face for hilighting variable scopes")
-(if (not (face-differs-from-default-p 'caml-types-scope-face))
-    (set-face-background 'caml-types-scope-face "#BBFFFF"))
 (overlay-put caml-types-scope-ovl 'face 'caml-types-scope-face)
 
+(defface caml-types-def-face '((t :background "#FF4444"))
+  "Face for highlighting binding occurrences.")
+
 (defvar caml-types-def-ovl (make-overlay 1 1))
-(make-face 'caml-types-def-face)
-(set-face-doc-string 'caml-types-def-face
-                     "face for hilighting binding occurrences")
-(if (not (face-differs-from-default-p 'caml-types-def-face))
-    (set-face-background 'caml-types-def-face "#FF4444"))
 (overlay-put caml-types-def-ovl 'face 'caml-types-def-face)
 
+(defface caml-types-occ-face '((t :background "#44FF44"))
+  "Face for highlighting variable occurrences.")
+
 (defvar caml-types-occ-ovl (make-overlay 1 1))
-(make-face 'caml-types-occ-face)
-(set-face-doc-string 'caml-types-occ-face
-                     "face for hilighting variable occurrences")
-(if (not (face-differs-from-default-p 'caml-types-occ-face))
-    (set-face-background 'caml-types-occ-face "#44FF44"))
 (overlay-put caml-types-occ-ovl 'face 'caml-types-occ-face)
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]