1 ;;; emh-face.el --- header highlighting in emh.
3 ;; Copyright (C) 1997 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Version: $Id: emh-face.el,v 0.5 1997-09-25 15:11:34 morioka Exp $
8 ;; Keywords: header, highlighting
10 ;; This file is part of emh.
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (defsubst emh-set-face-foreground (face color)
33 (set-face-foreground face color)
34 (error (message "Color `%s' is not found." color))
37 (defsubst emh-make-face-bold (face)
38 (set-face-font face (face-font 'bold))
41 (defsubst emh-make-face-italic (face)
42 (set-face-font face (face-font 'italic))
45 (or (find-face 'from-field-body)
47 (make-face 'from-field-body)
48 (emh-set-face-foreground 'from-field-body "dark slate blue")
49 (emh-make-face-bold 'from-field-body)
52 (or (find-face 'subject-field-body)
54 (make-face 'subject-field-body)
55 (emh-set-face-foreground 'subject-field-body "violet red")
56 (emh-make-face-bold 'subject-field-body)
59 (or (find-face 'to-field-body)
61 (make-face 'to-field-body)
62 (emh-set-face-foreground 'to-field-body "red")
63 (emh-make-face-bold 'to-field-body)
66 (or (find-face 'cc-field-body)
68 (make-face 'cc-field-body)
69 (emh-set-face-foreground 'cc-field-body "salmon")
70 (emh-make-face-bold 'cc-field-body)
73 (or (find-face 'reply-to-field-body)
75 (make-face 'reply-to-field-body)
76 (emh-set-face-foreground 'reply-to-field-body "salmon")
77 (emh-make-face-bold 'reply-to-field-body)
80 (or (find-face '-to-field-body)
82 (make-face '-to-field-body)
83 (emh-set-face-foreground '-to-field-body "red")
86 (or (find-face 'date-field-body)
88 (make-face 'date-field-body)
89 (emh-set-face-foreground 'date-field-body "blue violet")
90 (emh-make-face-bold 'date-field-body)
93 (or (find-face 'message-id-field-body)
95 (make-face 'message-id-field-body)
96 (emh-set-face-foreground 'message-id-field-body "royal blue")
97 (emh-make-face-bold 'message-id-field-body)
100 (or (find-face 'field-body)
102 (make-face 'field-body)
103 (emh-set-face-foreground 'field-body "dark green")
104 (emh-make-face-italic 'field-body)
107 (or (find-face 'field-name)
109 (make-face 'field-name)
110 (emh-set-face-foreground 'field-name "dark green")
111 (emh-make-face-bold 'field-name)
114 (defvar emh-header-face
115 '(("^From:" field-name from-field-body)
116 ("^Subject:" field-name subject-field-body)
117 ("^To:" field-name to-field-body)
118 ("^cc:" field-name cc-field-body)
119 ("^Reply-To:" field-name reply-to-field-body)
120 ("^.+-To:" field-name -to-field-body)
121 ("^Date:" field-name date-field-body)
122 ("^Message-Id:" field-name message-id-field-body)
123 (t field-name field-body)
126 (defun emh-highlight-header ()
127 (goto-char (point-min))
128 (while (looking-at "^[^:]+:")
129 (let* ((beg (match-beginning 0))
131 (end (std11-field-end))
132 (field-name (buffer-substring beg med))
134 (let ((rest emh-header-face))
136 (let* ((rule (car rest))
138 (if (and (stringp key)
139 (string-match key field-name))
140 (throw 'found (cdr rule))
142 (setq rest (cdr rest))
144 (cdr (assq t emh-header-face))
147 (overlay-put (make-overlay beg med) 'face (car rule))
148 (overlay-put (make-overlay med end) 'face (cadr rule))
159 ;;; emh-face.el ends here