Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] Emacs lisp: setting font faces
- Date: Mon, 18 Jun 2007 17:33:51 +0900
- From: "Josh Glover" <jmglov@example.com>
- Subject: [tlug] Emacs lisp: setting font faces
[I answered my own question whilst writing this email, but since I had already written most of it, here it is in case someone else finds it useful.]
I am one of those fools who loves him some syntax highlighting, so I have some spew like this in my ~/.xemacs/init.el:
;; Fontification settings ;; ==================================================
; Face to use for comments (set-face-foreground 'font-lock-comment-face "White")
; Face to use for function and variable names (set-face-foreground 'font-lock-function-name-face "SpringGreen") (make-face-bold 'font-lock-function-name-face) (set-face-foreground 'font-lock-variable-name-face "SpringGreen") (make-face-bold 'font-lock-variable-name-face) ; Face to use for strings and documentation strings (set-face-foreground 'font-lock-string-face "Orange") (set-face-foreground 'font-lock-doc-string-face "Orange") ; Face to use for preprocessor commands (set-face-foreground 'font-lock-preprocessor-face "Green") (make-face-bold 'font-lock-preprocessor-face) ; Face to use for keywords (set-face-foreground 'font-lock-keyword-face "Yellow") (make-face-bold 'font-lock-keyword-face) ; Face to use for reference names (set-face-foreground 'font-lock-reference-face "red3") (make-face-bold 'font-lock-reference-face) ; Face to use for type names (set-face-foreground 'font-lock-type-face "LightBlue") (make-face-bold 'font-lock-type-face)
;; ==================================================
Which works like a charm for cperl-mode, etc.
But now I'm trying to get MMM Mode[1] figured out so I can benefit from cperl-mode in Mason[2] code. It is currently giving me a solid beating, but that may be for another post if I cannot figure it out. :)
What I see from the manual is that MMM Mode uses its own faces:
http://www.xemacs.org/Documentation/packages/html/mmm_3.html#SEC20
So I have to add some crap like this to my init.el:
(set-face-background 'mmm-default-submode-face "Black") ; Face to use for function and variable names (set-face-foreground 'mmm-default-function-name-face "SpringGreen") (make-face-bold 'font-lock-function-name-face)
But I hate this, because if hell freezes over and I have to change my colour scheme, I have to change crap in multiple places.
I'd rather define some variables and use them.
And I figured out how to do that, so here is the section of my init.el that handles that now:
;; Fontification settings ;; ==================================================
(setq bg-colour "Black") (setq comment-colour "White") (setq code-colour "SpringGreen") (setq string-colour "Orange") (setq preproc-colour "Green") (setq keyword-colour "Yellow") (setq ref-colour "red3") (setq type-colour "LightBlue")
; Face to use for comments (set-face-foreground 'font-lock-comment-face comment-colour)
; Face to use for function and variable names (set-face-foreground 'font-lock-function-name-face code-colour) (make-face-bold 'font-lock-function-name-face) (set-face-foreground 'font-lock-variable-name-face code-colour) (make-face-bold 'font-lock-variable-name-face) ; Face to use for strings and documentation strings (set-face-foreground 'font-lock-string-face string-colour) (set-face-foreground 'font-lock-doc-string-face string-colour) ; Face to use for preprocessor commands (set-face-foreground 'font-lock-preprocessor-face preproc-colour) (make-face-bold 'font-lock-preprocessor-face) ; Face to use for keywords (set-face-foreground 'font-lock-keyword-face keyword-colour) (make-face-bold 'font-lock-keyword-face) ; Face to use for reference names (set-face-foreground 'font-lock-reference-face ref-colour) (make-face-bold 'font-lock-reference-face) ; Face to use for type names (set-face-foreground 'font-lock-type-face type-colour) (make-face-bold 'font-lock-type-face)
;; ==================================================
;; MMM Mode ;; ==================================================
(require 'mmm-auto) (setq mmm-global-mode 'maybe) (setq mmm-submode-decoration-level '2)
(set-face-background 'mmm-default-submode-face bg-colour)
(set-face-background 'mmm-init-submode-face bg-colour)
(set-face-background 'mmm-cleanup-submode-face bg-colour)
(set-face-background 'mmm-declaration-submode-face bg-colour)
(set-face-background 'mmm-comment-submode-face bg-colour) (set-face-foreground 'mmm-comment-submode-face comment-colour)
(set-face-background 'mmm-output-submode-face bg-colour)
(set-face-background 'mmm-code-submode-face bg-colour)
(set-face-background 'mmm-special-submode-face bg-colour)
;; ==================================================
Real Emacs Lisp hackers, if you have any improvements to suggest, have at it! :)
Cheers, Josh
[1] http://www.xemacs.org/Documentation/packages/html/mmm.html#SEC_Top [2] http://www.masonhq.com/
- Follow-Ups:
- [tlug] Emacs lisp: setting font faces
- From: Stephen J. Turnbull
Home | Main Index | Thread Index
- Prev by Date: [tlug] Re: WWW page charsets (was: font encoding question)
- Next by Date: [tlug] lesser kernel rpm install
- Previous by thread: [tlug] Re: WWW page charsets (was: font encoding question)
- Next by thread: [tlug] Emacs lisp: setting font faces
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links