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.2 1997-03-14 05:30:33 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 (or (find-face 'from-field-body)
39 (make-face 'from-field-body)
40 (emh-set-face-foreground 'from-field-body "dark slate blue")
41 (make-face-bold 'from-field-body nil 'no-error)
44 (or (find-face 'subject-field-body)
46 (make-face 'subject-field-body)
47 (emh-set-face-foreground 'subject-field-body "violet red")
48 (make-face-bold 'subject-field-body nil 'no-error)
51 (or (find-face 'to-field-body)
53 (make-face 'to-field-body)
54 (emh-set-face-foreground 'to-field-body "red")
55 (make-face-bold 'to-field-body nil 'no-error)
58 (or (find-face 'cc-field-body)
60 (make-face 'cc-field-body)
61 (emh-set-face-foreground 'cc-field-body "salmon")
62 (make-face-bold 'cc-field-body nil 'no-error)
65 (or (find-face 'reply-to-field-body)
67 (make-face 'reply-to-field-body)
68 (emh-set-face-foreground 'reply-to-field-body "salmon")
69 (make-face-bold 'reply-to-field-body nil 'no-error)
72 (or (find-face '-to-field-body)
74 (make-face '-to-field-body)
75 (emh-set-face-foreground '-to-field-body "red")
78 (or (find-face 'date-field-body)
80 (make-face 'date-field-body)
81 (emh-set-face-foreground 'date-field-body "blue violet")
82 (make-face-bold 'date-field-body nil 'no-error)
85 (or (find-face 'message-id-field-body)
87 (make-face 'message-id-field-body)
88 (emh-set-face-foreground 'message-id-field-body "royal blue")
89 (make-face-bold 'message-id-field-body nil 'no-error)
92 (or (find-face 'field-body)
94 (make-face 'field-body)
95 (emh-set-face-foreground 'field-body "dark green")
96 (make-face-italic 'field-body nil 'no-error)
99 (or (find-face 'field-name)
101 (make-face 'field-name)
102 (emh-set-face-foreground 'field-name "dark green")
103 (make-face-bold 'field-name nil 'no-error)
106 (defvar emh-header-face
107 '(("^From:" field-name from-field-body)
108 ("^Subject:" field-name subject-field-body)
109 ("^To:" field-name to-field-body)
110 ("^cc:" field-name cc-field-body)
111 ("^Reply-To:" field-name reply-to-field-body)
112 ("^.+-To:" field-name -to-field-body)
113 ("^Date:" field-name date-field-body)
114 ("^Message-Id:" field-name message-id-field-body)
115 (t field-name field-body)
118 (defun emh-highlight-header ()
119 (goto-char (point-min))
120 (while (looking-at "^[^:]+:")
121 (let* ((beg (match-beginning 0))
123 (end (std11-field-end))
124 (field-name (buffer-substring beg med))
125 (rule (cdr (or (assoc-if (function
128 (string-match key field-name)
131 (assq t emh-header-face)
134 (overlay-put (make-overlay beg med) 'face (car rule))
135 (overlay-put (make-overlay med end) 'face (second rule))
146 ;;; emh-face.el ends here