Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using COLOURS rather than FONTS in font-lock-mode: SUMMARY

0 views
Skip to first unread message

Simon Marshall

unread,
Nov 22, 1993, 8:19:38 AM11/22/93
to
Hi folks. I recently asked how I could easily get font-lock-mode to use
colours rather than fonts, and got a number of helpful replies. I'm
posting a summary of two different methods, the first of which is the
shortest, easiest, and the only one I've actually used myself. Thank you
to all those that replied. I should note that it's not as easy as you
might hope.

Method 1 (blu...@sni-usa.com):

;#########################################################################
;Font-lock mode stuff
;Face stuff
;#########################################################################

(add-hook 'c-mode-hook 'font-lock-mode)
(make-face 'comments)
(set-face-foreground 'comments "blue")
(setq font-lock-comment-face 'comments)

(make-face 'keywords)
(set-face-foreground 'keywords "DarkTurquoise")
(setq font-lock-keyword-face 'keywords)

(make-face 'function-name)
(set-face-foreground 'function-name "DarkSeaGreen")
(setq font-lock-function-name-face 'function-name)

(make-face 'string)
(set-face-foreground 'string "RosyBrown")
(setq font-lock-string-face 'string)

(make-face 'type)
(set-face-foreground 'type "blue")
(setq font-lock-type-face 'type)

Method 2 (sjo...@cwi.nl):

; get the faces from the X resources
(make-face 'font-lock-comment-face)
(make-face 'font-lock-doc-string-face)
(make-face 'font-lock-string-face)
(make-face 'font-lock-function-name-face)
(make-face 'font-lock-keyword-face)
(make-face 'font-lock-type-face)

; provide defaults for the faces
(or (face-differs-from-default-p 'font-lock-comment-face)
(copy-face 'italic 'font-lock-comment-face))

(or (face-differs-from-default-p 'font-lock-doc-string-face)
(copy-face 'font-lock-comment-face 'font-lock-doc-string-face))

(or (face-differs-from-default-p 'font-lock-string-face)
(progn
(copy-face 'font-lock-doc-string-face 'font-lock-string-face)
(set-face-underline-p 'font-lock-string-face t)))

(or (face-differs-from-default-p 'font-lock-function-name-face)
(copy-face 'bold-italic 'font-lock-function-name-face))

(or (face-differs-from-default-p 'font-lock-keyword-face)
(copy-face 'bold 'font-lock-keyword-face))

(or (face-differs-from-default-p 'font-lock-type-face)
(copy-face 'italic 'font-lock-type-face))

; the values of these variables are names of faces, not the faces themselves
(setq font-lock-comment-face 'font-lock-comment-face)
(setq font-lock-doc-string-face 'font-lock-doc-string-face)
(setq font-lock-string-face 'font-lock-string-face)
(setq font-lock-function-name-face 'font-lock-function-name-face)
(setq font-lock-keyword-face 'font-lock-keyword-face)
(setq font-lock-type-face 'font-lock-type-face)
(setq italic 'italic
bold 'bold
bold-italic 'bold-italic
underline 'underline)

And in my .Xresources file I have the following (together with a lot
of other colors):

Emacs*font-lock-comment-face.attributeForeground: #ffff99
Emacs*font-lock-function-name-face.attributeForeground: #99ffff
Emacs*font-lock-keyword-face.attributeForeground: white
Emacs*font-lock-string-face.attributeForeground: #eeddbb
Emacs*font-lock-symbol-face.attributeForeground: #eebbdd

Hope this is of use to people out there, Si.
_______________________________________________________________________________
Simon Marshall, ESRIN (ESA), Via Galileo Galilei, Frascati 00044 (Roma), Italia
"Football isn't about life and death. It's more important than that." Shanks.
Email: Simon.M...@mail.esrin.esa.it Voice: +39 6 941 80 707 Fax: 80 361

0 new messages