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.0 1997-03-04 20:17:52 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.
29 (or (find-face 'from-field-body)
31 (make-face 'from-field-body)
32 (and (member "blue" (x-defined-colors))
33 (set-face-foreground 'from-field-body "blue")
36 (or (find-face 'from-field-name)
38 (copy-face 'from-field-body 'from-field-name)
39 (make-face-bold 'from-field-name nil 'no-error)
42 (or (find-face 'subject-field-body)
44 (make-face 'subject-field-body)
45 (and (member "violet red" (x-defined-colors))
46 (set-face-foreground 'subject-field-body "violet red")
49 (or (find-face 'subject-field-name)
51 (copy-face 'subject-field-body 'subject-field-name)
52 (make-face-bold 'subject-field-name nil 'no-error)
55 (or (find-face 'to-field-body)
57 (make-face 'to-field-body)
58 (and (member "red" (x-defined-colors))
59 (set-face-foreground 'to-field-body "red")
62 (or (find-face 'to-field-name)
64 (copy-face 'to-field-body 'to-field-name)
65 (make-face-bold 'to-field-name nil 'no-error)
68 (or (find-face 'cc-field-body)
70 (make-face 'cc-field-body)
71 (and (member "pink" (x-defined-colors))
72 (set-face-foreground 'cc-field-body "pink")
75 (or (find-face 'cc-field-name)
77 (copy-face 'cc-field-body 'cc-field-name)
78 (make-face-bold 'cc-field-name nil 'no-error)
81 (or (find-face '-to-field-body)
83 (make-face '-to-field-body)
84 (and (member "salmon" (x-defined-colors))
85 (set-face-foreground '-to-field-body "salmon")
88 (or (find-face '-to-field-name)
90 (copy-face '-to-field-body '-to-field-name)
91 (make-face-bold '-to-field-name nil 'no-error)
94 (or (find-face 'date-field-body)
96 (make-face 'date-field-body)
97 (and (member "blue violet" (x-defined-colors))
98 (set-face-foreground 'date-field-body "blue violet")
101 (or (find-face 'date-field-name)
103 (copy-face 'date-field-body 'date-field-name)
104 (make-face-bold 'date-field-name nil 'no-error)
107 (or (find-face 'message-id-field-body)
109 (make-face 'message-id-field-body)
110 (and (member "royal blue" (x-defined-colors))
111 (set-face-foreground 'message-id-field-body "royal blue")
114 (or (find-face 'message-id-field-name)
116 (copy-face 'message-id-field-body 'message-id-field-name)
117 (make-face-bold 'message-id-field-name nil 'no-error)
120 (or (find-face 'field-body)
122 (make-face 'field-body)
123 (and (member "dark green" (x-defined-colors))
124 (set-face-foreground 'field-body "dark green")
126 (make-face-italic 'field-body nil 'no-error)
128 (or (find-face 'field-name)
130 (make-face 'field-name)
131 (and (member "dark green" (x-defined-colors))
132 (set-face-foreground 'field-name "dark green")
134 (make-face-bold 'field-name nil 'no-error)
137 (defvar emh-header-face
138 '(("^From:" from-field-name from-field-body)
139 ("^Subject:" subject-field-name subject-field-body)
140 ("^To:" to-field-name to-field-body)
141 ("^cc:" cc-field-name cc-field-body)
142 ("^.+-To:" -to-field-name -to-field-body)
143 ("^Date:" date-field-name date-field-body)
144 ("^Message-Id:" message-id-field-name message-id-field-body)
145 (t field-name field-body)
148 (defun emh-highlight-header ()
149 (goto-char (point-min))
150 (while (looking-at "^[^:]+:")
151 (let* ((beg (match-beginning 0))
153 (end (std11-field-end))
154 (field-name (buffer-substring beg med))
155 (rule (cdr (or (assoc-if (function
158 (string-match key field-name)
161 (assq t emh-header-face)
164 (overlay-put (make-overlay beg med) 'face (car rule))
165 (overlay-put (make-overlay med end) 'face (second rule))
176 ;;; emh-face.el ends here