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 22:26:30 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: [tlug] Emacs lisp: setting font faces
- References: <d8fcc0800706180133t7355e719x8ce6bc771ab266f3@mail.gmail.com>
Josh Glover writes: > 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. Well, for starters, it should be possible to inherit faces (but it currently doesn't work right in XEmacs). Even though you've got it all in one place in the source (init.el), it's bara-bara in the running Emacs. This stuff is hardly performance-critical. So, I would suggest a hash table: (setq colour-role-table (make-hash-table :test 'eq)) (mapc (lambda (x) (puthash (nth 0 x) (nth 1 x) colour-role-table)) '((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 ;; Generalization of the function below to handle additional styles ;; (such as bold or italic) is left to the reader. (set-face-foreground 'font-lock-comment-face comment-colour) ;; This lambda, or even the mapc, could be encapsulated in a named ;; function. (mapc (lambda (x) (set-face-foreground (nth 0 x) (gethash (nth 1) colour-role-table)) (make-face-bold (nth 0 x))) '( ; Face to use for function and variable names (font-lock-function-name-face code-colour) (font-lock-variable-name-face code-colour) ; Face to use for strings and documentation strings (font-lock-string-face string-colour) (font-lock-doc-string-face string-colour) ; Face to use for preprocessor commands (font-lock-preprocessor-face preproc-colour) ; Face to use for keywords (font-lock-keyword-face keyword-colour) ; Face to use for reference names (font-lock-reference-face ref-colour) ; Face to use for type names (font-lock-type-face type-colour))) (when you-want-to-see-whats-in-the-table (with-displaying-temp-buffer ;; Sorting is left as an exercise for the reader. ;; If you want to be sure to have the same order as in the data list ;; above, use external plists rather than a hash table (homework). ;; Hint: C-x f plist-put RET. (maphash (lambda (key value) (princ (format "%32s%s\n" key value)))))) N.B. The above isn't quite right, I've messed up which faces should be bolded.
- References:
- [tlug] Emacs lisp: setting font faces
- From: Josh Glover
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] More joy with MMM Mode in XEmacs
- Next by Date: Re: [tlug] lesser kernel rpm install
- Previous by thread: [tlug] Emacs lisp: setting font faces
- Next by thread: [tlug] lesser kernel rpm install
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links