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.3 1997-03-14 05:41:55 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)
40 (error (message "Can not make bold face `%s'." face))
43 (defsubst emh-make-face-italic (face)
46 (error (message "Can not make italic face `%s'." face))
49 (or (find-face 'from-field-body)
51 (make-face 'from-field-body)
52 (emh-set-face-foreground 'from-field-body "dark slate blue")
53 (emh-make-face-bold 'from-field-body)
56 (or (find-face 'subject-field-body)
58 (make-face 'subject-field-body)
59 (emh-set-face-foreground 'subject-field-body "violet red")
60 (emh-make-face-bold 'subject-field-body)
63 (or (find-face 'to-field-body)
65 (make-face 'to-field-body)
66 (emh-set-face-foreground 'to-field-body "red")
67 (emh-make-face-bold 'to-field-body)
70 (or (find-face 'cc-field-body)
72 (make-face 'cc-field-body)
73 (emh-set-face-foreground 'cc-field-body "salmon")
74 (emh-make-face-bold 'cc-field-body)
77 (or (find-face 'reply-to-field-body)
79 (make-face 'reply-to-field-body)
80 (emh-set-face-foreground 'reply-to-field-body "salmon")
81 (emh-make-face-bold 'reply-to-field-body)
84 (or (find-face '-to-field-body)
86 (make-face '-to-field-body)
87 (emh-set-face-foreground '-to-field-body "red")
90 (or (find-face 'date-field-body)
92 (make-face 'date-field-body)
93 (emh-set-face-foreground 'date-field-body "blue violet")
94 (emh-make-face-bold 'date-field-body)
97 (or (find-face 'message-id-field-body)
99 (make-face 'message-id-field-body)
100 (emh-set-face-foreground 'message-id-field-body "royal blue")
101 (emh-make-face-bold 'message-id-field-body)
104 (or (find-face 'field-body)
106 (make-face 'field-body)
107 (emh-set-face-foreground 'field-body "dark green")
108 (emh-make-face-italic 'field-body)
111 (or (find-face 'field-name)
113 (make-face 'field-name)
114 (emh-set-face-foreground 'field-name "dark green")
115 (emh-make-face-bold 'field-name)
118 (defvar emh-header-face
119 '(("^From:" field-name from-field-body)
120 ("^Subject:" field-name subject-field-body)
121 ("^To:" field-name to-field-body)
122 ("^cc:" field-name cc-field-body)
123 ("^Reply-To:" field-name reply-to-field-body)
124 ("^.+-To:" field-name -to-field-body)
125 ("^Date:" field-name date-field-body)
126 ("^Message-Id:" field-name message-id-field-body)
127 (t field-name field-body)
130 (defun emh-highlight-header ()
131 (goto-char (point-min))
132 (while (looking-at "^[^:]+:")
133 (let* ((beg (match-beginning 0))
135 (end (std11-field-end))
136 (field-name (buffer-substring beg med))
137 (rule (cdr (or (assoc-if (function
140 (string-match key field-name)
143 (assq t emh-header-face)
146 (overlay-put (make-overlay beg med) 'face (car rule))
147 (overlay-put (make-overlay med end) 'face (second rule))
158 ;;; emh-face.el ends here