1 ;;; wl-highlight.el --- Hilight modules for Wanderlust.
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
4 ;; Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Keywords: mail, net news
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
33 (if (and (featurep 'xemacs)
37 (provide 'wl-highlight) ; circular dependency
46 (defun-maybe wl-dnd-set-drop-target (a b))
47 (defun-maybe wl-dnd-set-drag-starter (a b)))
49 (put 'wl-defface 'lisp-indent-function 'defun)
51 (defgroup wl-faces nil
53 :prefix "wl-highlight-"
57 (defgroup wl-summary-faces nil
58 "Wanderlust, Faces of summary buffer."
59 :prefix "wl-highlight-"
63 (defgroup wl-folder-faces nil
64 "Wanderlust, Faces of folder buffer."
65 :prefix "wl-highlight-"
69 (defgroup wl-message-faces nil
70 "Wanderlust, Faces of message buffer."
71 :prefix "wl-highlight-"
74 ;; for message header and signature
76 (wl-defface wl-highlight-message-headers
83 (:foreground "gray" :bold t))
86 (:foreground "gray50" :bold t)))
87 "Face used for displaying header names."
88 :group 'wl-message-faces
91 (wl-defface wl-highlight-message-header-contents
95 (:foreground "green"))
98 (:foreground "LightSkyBlue" :bold t))
101 (:foreground "purple" :bold t)))
102 "Face used for displaying header content."
103 :group 'wl-message-faces
106 (wl-defface wl-highlight-message-important-header-contents
110 (:foreground "yellow"))
113 (:foreground "yellow" :bold t))
116 (:foreground "brown" :bold t)))
117 "Face used for displaying contents of special headers."
118 :group 'wl-message-faces
121 (wl-defface wl-highlight-message-important-header-contents2
128 (:foreground "orange" :bold t))
131 (:foreground "DarkSlateBlue" :bold t)))
132 "Face used for displaying contents of special headers."
133 :group 'wl-message-faces
136 (wl-defface wl-highlight-message-citation-header
140 (:foreground "cyan"))
143 (:foreground "SkyBlue"))
146 (:foreground "DarkGreen")))
147 "Face used for displaying header of quoted texts."
148 :group 'wl-message-faces
151 (wl-defface wl-highlight-message-unimportant-header-contents
155 (:foreground "green"))
158 (:foreground "GreenYellow" :bold t))
161 (:foreground "DarkGreen" :bold t)))
162 "Face used for displaying contents of unimportant headers."
163 :group 'wl-message-faces
166 (wl-defface wl-highlight-message-signature
169 (:foreground "khaki"))
172 (:foreground "DarkSlateBlue")))
173 "Face used for displaying signature."
174 :group 'wl-message-faces
179 (wl-defface wl-highlight-header-separator-face
183 (:foreground "black" :background "yellow"))
185 (:foreground "Black" :background "DarkKhaki")))
186 "Face used for displaying header separator."
190 ;; important messages
192 (wl-defface wl-highlight-summary-important-face
196 (:foreground "magenta"))
199 (:foreground "orange"))
202 (:foreground "purple")))
203 "Face used for displaying important messages."
204 :group 'wl-summary-faces
207 (wl-defface wl-highlight-summary-new-face
214 (:foreground "tomato"))
217 (:foreground "tomato")))
218 "Face used for displaying new messages."
219 :group 'wl-summary-faces
222 (wl-defface wl-highlight-summary-displaying-face
224 (:underline t :bold t)))
225 "Face used for displaying message."
226 :group 'wl-summary-faces
229 (wl-defface wl-highlight-thread-indent-face
231 (:foreground "gray40")))
232 "Face used for displaying indented thread."
233 :group 'wl-summary-faces
236 ;; unimportant messages
238 (wl-defface wl-highlight-summary-unread-face
242 (:foreground "cyan"))
245 (:foreground "LightSkyBlue"))
248 (:foreground "RoyalBlue")))
249 "Face used for displaying unread messages."
250 :group 'wl-summary-faces
253 (wl-defface wl-highlight-summary-disposed-face
257 (:foreground "blue"))
260 (:foreground "gray"))
263 (:foreground "DarkKhaki")))
264 "Face used for displaying messages mark as disposed."
265 :group 'wl-summary-faces
268 (wl-defface wl-highlight-summary-deleted-face
272 (:foreground "blue"))
275 (:foreground "SteelBlue"))
278 (:foreground "RoyalBlue4")))
279 "Face used for displaying messages mark as deleted."
280 :group 'wl-summary-faces
283 (wl-defface wl-highlight-summary-prefetch-face
287 (:foreground "Green"))
290 (:foreground "DeepSkyBlue"))
293 (:foreground "brown")))
294 "Face used for displaying messages mark as deleted."
295 :group 'wl-summary-faces
298 (wl-defface wl-highlight-summary-resend-face
302 (:foreground "Yellow"))
305 (:foreground "orange3"))
308 (:foreground "orange3")))
309 "Face used for displaying messages mark as resend."
310 :group 'wl-summary-faces
313 (wl-defface wl-highlight-summary-refiled-face
317 (:foreground "blue"))
320 (:foreground "blue"))
323 (:foreground "firebrick")))
324 "Face used for displaying messages mark as refiled."
325 :group 'wl-summary-faces
328 (wl-defface wl-highlight-summary-copied-face
332 (:foreground "blue"))
335 (:foreground "cyan"))
338 (:foreground "blue")))
339 "Face used for displaying messages mark as copied."
340 :group 'wl-summary-faces
344 (wl-defface wl-highlight-summary-answered-face
347 (:foreground "yellow"))
350 (:foreground "khaki"))
353 (:foreground "khaki4")))
354 "Face used for displaying answered messages."
355 :group 'wl-summary-faces
359 (wl-defface wl-highlight-summary-temp-face
363 (:foreground "gold"))
365 (:foreground "HotPink1")))
366 "Face used for displaying messages mark as temp."
367 :group 'wl-summary-faces
370 (wl-defface wl-highlight-summary-target-face
374 (:foreground "gold"))
376 (:foreground "HotPink1")))
377 "Face used for displaying messages mark as target."
378 :group 'wl-summary-faces
381 (wl-defface wl-highlight-summary-low-read-face
385 (:foreground "yellow" :italic t))
388 (:foreground "PaleGreen" :italic t))
391 (:foreground "Green3" :italic t)))
392 "Face used for displaying low interest read messages."
393 :group 'wl-summary-faces
396 (wl-defface wl-highlight-summary-high-read-face
402 (:foreground "PaleGreen" :bold t))
405 (:foreground "SeaGreen" :bold t)))
406 "Face used for displaying high interest read messages."
407 :group 'wl-summary-faces
410 (wl-defface wl-highlight-summary-low-unread-face
414 (:foreground "cyan" :italic t))
417 (:foreground "LightSkyBlue" :italic t))
420 (:foreground "RoyalBlue" :italic t)))
421 "Face used for displaying low interest unread messages."
422 :group 'wl-summary-faces
425 (wl-defface wl-highlight-summary-high-unread-face
428 (:foreground "red" :bold t))
431 (:foreground "tomato" :bold t))
434 (:foreground "tomato" :bold t)))
435 "Face used for displaying high interest unread messages."
436 :group 'wl-summary-faces
441 (wl-defface wl-highlight-summary-thread-top-face
445 (:foreground "green"))
448 (:foreground "GreenYellow"))
451 (:foreground "green4")))
452 "Face used for displaying top thread message."
453 :group 'wl-summary-faces
456 (wl-defface wl-highlight-summary-normal-face
460 (:foreground "yellow"))
463 (:foreground "PaleGreen"))
466 (:foreground "SeaGreen")))
467 "Face used for displaying normal message."
468 :group 'wl-summary-faces
473 (wl-defface wl-highlight-folder-unknown-face
477 (:foreground "cyan"))
480 (:foreground "pink"))
483 (:foreground "RoyalBlue")))
484 "Face used for displaying unread folder."
485 :group 'wl-folder-faces
488 (wl-defface wl-highlight-folder-killed-face
492 (:foreground "gray"))
494 (:foreground "gray50")))
495 "Face used for displaying killed folder."
496 :group 'wl-folder-faces
499 (wl-defface wl-highlight-folder-zero-face
503 (:foreground "green"))
506 (:foreground "SkyBlue"))
509 (:foreground "BlueViolet")))
510 "Face used for displaying folder needs no sync."
511 :group 'wl-folder-faces
514 (wl-defface wl-highlight-folder-few-face
518 (:foreground "yellow"))
521 (:foreground "orange"))
524 (:foreground "OrangeRed3")))
525 "Face used for displaying folder contains few unsync messages."
526 :group 'wl-folder-faces
529 (wl-defface wl-highlight-folder-many-face
536 (:foreground "HotPink1"))
539 (:foreground "tomato")))
540 "Face used for displaying folder contains many unsync messages."
541 :group 'wl-folder-faces
544 (wl-defface wl-highlight-folder-unread-face
548 (:foreground "magenta"))
551 (:foreground "gold"))
554 (:foreground "MediumVioletRed")))
555 "Face used for displaying unread folder."
556 :group 'wl-folder-faces
559 (wl-defface wl-highlight-folder-opened-face
563 (:foreground "blue"))
566 (:foreground "PaleGreen"))
569 (:foreground "ForestGreen")))
570 "Face used for displaying opened group folder."
571 :group 'wl-folder-faces
574 (wl-defface wl-highlight-folder-closed-face
578 (:foreground "cyan"))
581 (:foreground "GreenYellow"))
584 (:foreground "DarkOliveGreen4")))
585 "Face used for displaying closed group folder."
586 :group 'wl-folder-faces
589 (wl-defface wl-highlight-folder-path-face
591 (:bold t :underline t)))
592 "Face used for displaying path."
593 :group 'wl-folder-faces
596 (wl-defface wl-highlight-demo-face
598 (:foreground "green"))
601 (:foreground "#006600" :background "#d9ffd9"))
604 (:foreground "#d9ffd9" :background "#004400")))
605 "Face used for displaying demo."
608 (wl-defface wl-highlight-logo-face
611 (:foreground "cyan"))
614 (:foreground "SkyBlue"))
617 (:foreground "SteelBlue")))
618 "Face used for displaying demo."
621 (wl-defface wl-highlight-action-argument-face
624 (:foreground "pink"))
627 (:foreground "red")))
628 "Face used for displaying action argument."
629 :group 'wl-summary-faces
634 (wl-defface wl-highlight-message-cited-text-1
638 (:foreground "magenta"))
641 (:foreground "HotPink1"))
644 (:foreground "ForestGreen")))
645 "Face used for displaying quoted text from other messages."
646 :group 'wl-message-faces
649 (wl-defface wl-highlight-message-cited-text-2
653 (:foreground "blue"))
655 (:foreground "violet")))
656 "Face used for displaying quoted text from other messages."
657 :group 'wl-message-faces
660 (wl-defface wl-highlight-message-cited-text-3
664 (:foreground "cyan"))
666 (:foreground "orchid3")))
667 "Face used for displaying quoted text from other messages."
668 :group 'wl-message-faces
671 (wl-defface wl-highlight-message-cited-text-4
675 (:foreground "green"))
677 (:foreground "purple1")))
678 "Face used for displaying quoted text from other messages."
679 :group 'wl-message-faces
682 (wl-defface wl-highlight-message-cited-text-5
686 (:foreground "yellow"))
688 (:foreground "MediumPurple1")))
689 "Face used for displaying quoted text from other messages."
690 :group 'wl-message-faces
693 (wl-defface wl-highlight-message-cited-text-6
699 (:foreground "PaleVioletRed")))
700 "Face used for displaying quoted text from other messages."
701 :group 'wl-message-faces
704 (wl-defface wl-highlight-message-cited-text-7
708 (:foreground "magenta"))
710 (:foreground "LightPink")))
711 "Face used for displaying quoted text from other messages."
712 :group 'wl-message-faces
715 (wl-defface wl-highlight-message-cited-text-8
719 (:foreground "blue"))
721 (:foreground "salmon")))
722 "Face used for displaying quoted text from other messages."
723 :group 'wl-message-faces
726 (wl-defface wl-highlight-message-cited-text-9
730 (:foreground "cyan"))
732 (:foreground "SandyBrown")))
733 "Face used for displaying quoted text from other messages."
734 :group 'wl-message-faces
737 (wl-defface wl-highlight-message-cited-text-10
741 (:foreground "green"))
743 (:foreground "wheat")))
744 "Face used for displaying quoted text from other messages."
745 :group 'wl-message-faces
748 (defface wl-message-header-narrowing-face
749 '((((class color) (background light))
750 (:foreground "black" :background "dark khaki"))
751 (((class color) (background dark))
752 (:foreground "white" :background "dark goldenrod"))
754 "Face used for header narrowing for the message."
755 :group 'wl-message-faces
758 (defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
759 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
760 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
762 (defvar wl-highlight-citation-face-list
763 '(wl-highlight-message-cited-text-1
764 wl-highlight-message-cited-text-2
765 wl-highlight-message-cited-text-3
766 wl-highlight-message-cited-text-4
767 wl-highlight-message-cited-text-5
768 wl-highlight-message-cited-text-6
769 wl-highlight-message-cited-text-7
770 wl-highlight-message-cited-text-8
771 wl-highlight-message-cited-text-9
772 wl-highlight-message-cited-text-10))
774 (defmacro wl-delete-all-overlays ()
775 "Delete all momentary overlays."
776 '(let ((overlays (overlays-in (point-min) (point-max)))
778 (while (setq overlay (car overlays))
779 (if (overlay-get overlay 'wl-momentary-overlay)
780 (delete-overlay overlay))
781 (setq overlays (cdr overlays)))))
783 (defun wl-highlight-summary-displaying ()
785 (wl-delete-all-overlays)
792 (setq ov (make-overlay bol eol))
793 (overlay-put ov 'face 'wl-highlight-summary-displaying-face)
794 (overlay-put ov 'evaporate t)
795 (overlay-put ov 'wl-momentary-overlay t))))
797 (defun wl-highlight-folder-group-line (numbers)
803 (let ((text-face (cond ((looking-at wl-highlight-folder-opened-regexp)
804 'wl-highlight-folder-opened-face)
805 ((looking-at wl-highlight-folder-closed-regexp)
806 'wl-highlight-folder-closed-face))))
807 (if (and wl-highlight-folder-by-numbers
808 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" eol t))
809 (let* ((unsync (nth 0 numbers))
810 (unread (nth 1 numbers))
811 (face (cond ((and unsync (zerop unsync))
812 (if (and unread (> unread 0))
813 'wl-highlight-folder-unread-face
814 'wl-highlight-folder-zero-face))
816 (>= unsync wl-folder-many-unsync-threshold))
817 'wl-highlight-folder-many-face)
819 'wl-highlight-folder-few-face))))
820 (if (numberp wl-highlight-folder-by-numbers)
822 (put-text-property bol (match-beginning 0) 'face text-face)
823 (put-text-property (match-beginning 0) (match-end 0)
825 ;; Remove previous face.
826 (put-text-property bol (match-end 0) 'face nil)
827 (put-text-property bol (match-end 0) 'face face)))
828 (put-text-property bol eol 'face text-face)))))
830 (defsubst wl-highlight-summary-line-face-spec (flags temp-mark indent)
831 "Return a cons cell of (face . argument)."
833 (if (setq action (assoc temp-mark wl-summary-mark-action-list))
834 (cons (nth 5 action) (nth 2 action))
836 ((and (string= temp-mark wl-summary-score-over-mark)
837 (or (memq 'new flags) (memq 'unread flags)))
838 '(wl-highlight-summary-high-unread-face))
839 ((and (string= temp-mark wl-summary-score-below-mark)
840 (or (memq 'new flags) (memq 'unread flags)))
841 '(wl-highlight-summary-low-unread-face))
842 ((let ((priorities wl-summary-persistent-mark-priority-list)
843 (fl wl-summary-flag-alist)
844 face result global-flags)
845 (while (and (null result) priorities)
846 (if (and (eq (car priorities) 'flag)
848 (elmo-get-global-flags flags 'ignore-preserved)))
850 (when (memq (car (car fl)) global-flags)
855 "wl-highlight-summary-%s-flag-face"
858 (make-face face 'no-init)
859 (set-face-foreground face (nth 1 (car fl))))
863 (when (memq (car priorities) flags)
867 "wl-highlight-summary-%s-face"
871 (setq priorities (cdr priorities)))
873 ((string= temp-mark wl-summary-score-below-mark)
874 '(wl-highlight-summary-low-read-face))
875 ((string= temp-mark wl-summary-score-over-mark)
876 '(wl-highlight-summary-high-read-face))
878 '(wl-highlight-summary-normal-face)
879 '(wl-highlight-summary-thread-top-face)))))))
881 (defun wl-highlight-summary-line-flag-folder (number beg end &optional string)
882 ;; help-echo for flag folder.
885 (when (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
888 (elmo-flag-folder-referrer wl-summary-buffer-elmo-folder
891 (put-text-property beg end 'help-echo
892 (concat "The message exists in "
895 (concat (car pair) "/"
901 (defun wl-highlight-summary-line-string (number line flags temp-mark indent)
902 (let ((fsymbol (car (wl-highlight-summary-line-face-spec
905 (> (length indent) 0)))))
906 (put-text-property 0 (length line) 'face fsymbol line))
907 (when wl-use-highlight-mouse-line
908 (put-text-property 0 (length line) 'mouse-face 'highlight line))
909 (when wl-use-flag-folder-help-echo
910 (wl-highlight-summary-line-flag-folder number 0 (length line) line)))
912 (defun wl-highlight-summary-current-line (&optional number flags)
915 (let ((inhibit-read-only t)
916 (case-fold-search nil)
917 (deactivate-mark nil)
918 (number (or number (wl-summary-message-number)))
924 (setq spec (wl-highlight-summary-line-face-spec
926 (elmo-message-flags wl-summary-buffer-elmo-folder
928 (wl-summary-temp-mark number)
929 (wl-thread-entity-get-parent-entity
930 (wl-thread-get-entity number))))
932 (put-text-property bol eol 'face (car spec)))
934 (put-text-property (next-single-property-change
935 (next-single-property-change
936 bol 'wl-summary-action-argument
938 'wl-summary-action-argument nil eol)
941 'wl-highlight-action-argument-face))
942 (when wl-use-highlight-mouse-line
943 (put-text-property bol eol 'mouse-face 'highlight))
944 (when wl-use-flag-folder-help-echo
945 (wl-highlight-summary-line-flag-folder number bol eol))
947 (wl-dnd-set-drag-starter bol eol)))))
949 (defun wl-highlight-folder (start end)
950 "Highlight folder between start and end.
952 wl-highlight-folder-unknown-face unread messages
953 wl-highlight-folder-zero-face folder needs no sync
954 wl-highlight-folder-few-face folder contains few unsync messages
955 wl-highlight-folder-many-face folder contains many unsync messages
956 wl-highlight-folder-opened-face opened group folder
957 wl-highlight-folder-closed-face closed group folder
960 wl-highlight-folder-opened-regexp matches opened group folder
961 wl-highlight-folder-closed-regexp matches closed group folder
965 (let ((s start)) (setq start end end s)))
966 (let* ((lines (count-lines start end))
972 (narrow-to-region start end)
976 (wl-highlight-folder-current-line)
977 (forward-line 1)))))))
979 (defun wl-highlight-folder-path (folder-path)
980 "Highlight current folder path...overlay"
982 (wl-delete-all-overlays)
983 (let ((fp folder-path) ov)
984 (goto-char (point-min))
988 (or (looking-at "^[ ]*\\[[\\+-]\\]\\(.+\\):.*\n")
989 (looking-at "^[ ]*\\([^ \\[].+\\):.*\n"))
991 (get-text-property (point) 'wl-folder-entity-id)
994 (setq ov (make-overlay
997 (setq wl-folder-buffer-cur-point (point))
998 (overlay-put ov 'face 'wl-highlight-folder-path-face)
999 (overlay-put ov 'evaporate t)
1000 (overlay-put ov 'wl-momentary-overlay t))
1001 (forward-line 1)))))
1003 (defun wl-highlight-action-argument-string (string)
1004 (put-text-property 0 (length string) 'face
1005 'wl-highlight-action-argument-face
1008 (defun wl-highlight-summary-all ()
1011 (wl-highlight-summary (point-min)(point-max)))
1013 (defun wl-highlight-summary (start end &optional lazy)
1014 "Highlight summary between start and end.
1016 wl-highlight-summary-unread-face unread messages
1017 wl-highlight-summary-important-face important messages
1018 wl-highlight-summary-deleted-face messages mark as deleted
1019 wl-highlight-summary-refiled-face messages mark as refiled
1020 wl-highlight-summary-copied-face messages mark as copied
1021 wl-highlight-summary-new-face new messages"
1023 (let ((s start)) (setq start end end s)))
1024 (let (lines too-big gc-message e p hend i percent)
1026 (unless wl-summary-lazy-highlight
1027 (setq lines (count-lines start end)
1028 too-big (and wl-highlight-max-summary-lines
1029 (> lines wl-highlight-max-summary-lines))))
1032 (while (and (not (eobp))
1034 (when (or (not lazy)
1035 (null (get-text-property (point) 'face)))
1036 (wl-highlight-summary-current-line))
1038 (unless wl-summary-lazy-highlight
1039 (message "Highlighting...done")))))
1041 (defun wl-highlight-summary-window (&optional win beg)
1042 "Highlight summary window.
1043 This function is defined for `window-scroll-functions'"
1044 (when wl-summary-highlight
1045 (with-current-buffer (window-buffer win)
1046 (when (eq major-mode 'wl-summary-mode)
1047 (let ((start (window-start win))
1048 (end (condition-case nil
1049 (window-end win t) ;; old emacsen doesn't support 2nd arg.
1050 (error (window-end win)))))
1051 (wl-highlight-summary start
1054 (set-buffer-modified-p nil)))))
1056 (defun wl-highlight-headers (&optional for-draft)
1057 (let ((beg (point-min))
1058 (end (or (save-excursion (re-search-forward "^$" nil t)
1061 (wl-highlight-message beg end nil)
1063 (when wl-highlight-x-face-function
1064 (funcall wl-highlight-x-face-function)))
1065 (run-hooks 'wl-highlight-headers-hook)))
1067 (defun wl-highlight-body-all ()
1068 (wl-highlight-message (point-min) (point-max) t t))
1070 (defun wl-highlight-body ()
1071 (let ((beg (or (save-excursion (goto-char (point-min))
1072 (re-search-forward "^$" nil t))
1075 (wl-highlight-message beg end t)))
1077 (defun wl-highlight-body-region (beg end)
1078 (wl-highlight-message beg end t t))
1080 (defun wl-highlight-signature-search-simple (beg end)
1081 "Search signature area in the body message between BEG and END.
1082 Returns start point of signature."
1085 (if (re-search-backward "\n--+ *\n" beg t)
1086 (if (eq (char-after (point)) ?\n)
1091 (defun wl-highlight-signature-search (beg end)
1092 "Search signature area in the body message between BEG and END.
1093 Returns start point of signature."
1097 ;; look for legal signature separator (check at first for fasten)
1098 (re-search-backward "\n-- \n" beg t)
1100 ;; look for dual separator
1103 (re-search-backward "^[^A-Za-z0-9> \t\n]+ *$" beg t)
1104 (> (- (match-end 0) (match-beginning 0)) 10);; "10" is a magic number.
1107 (regexp-quote (buffer-substring (match-beginning 0) (match-end 0)))
1110 ;; look for user specified signature-separator
1111 (if (stringp wl-highlight-signature-separator)
1112 (re-search-backward wl-highlight-signature-separator nil t);; case one string
1113 (let ((sep wl-highlight-signature-separator)) ;; case list
1115 (not (re-search-backward (car sep) beg t)))
1116 (setq sep (cdr sep)))
1117 (point))) ;; if no separator found, returns end.
1120 (defun wl-highlight-message (start end hack-sig &optional body-only)
1121 "Highlight message headers between start and end.
1123 wl-highlight-message-headers the part before the colon
1124 wl-highlight-message-header-contents the part after the colon
1125 wl-highlight-message-important-header-contents contents of \"important\"
1127 wl-highlight-message-important-header-contents2 contents of \"important\"
1129 wl-highlight-message-unimportant-header-contents contents of unimportant
1131 wl-highlight-message-cited-text quoted text from other
1133 wl-highlight-message-citation-header header of quoted texts
1134 wl-highlight-message-signature signature
1137 wl-highlight-important-header-regexp what makes a \"important\" header
1138 wl-highlight-important-header2-regexp what makes a \"important\" header
1139 wl-highlight-unimportant-header-regexp what makes a \"not important\" header
1140 wl-highlight-citation-prefix-regexp matches lines of quoted text
1141 wl-highlight-citation-header-regexp matches headers for quoted text
1143 If HACK-SIG is true,then we search backward from END for something that
1144 looks like the beginning of a signature block, and don't consider that a
1145 part of the message (this is because signatures are often incorrectly
1146 interpreted as cited text.)"
1148 (let ((s start)) (setq start end end s)))
1149 (let ((too-big (and wl-highlight-max-message-size
1151 wl-highlight-max-message-size)))
1159 ;; take off signature
1160 (if (and hack-sig (not too-big))
1161 (setq end (funcall wl-highlight-signature-search-function
1162 (- end wl-max-signature-size) end)))
1164 (not (eq end real-end)))
1165 (put-text-property end (point-max)
1166 'face 'wl-highlight-message-signature))
1167 (narrow-to-region start end)
1169 ;; narrow down to just the headers...
1171 ;; If this search fails then the narrowing performed above
1173 (if (re-search-forward (format
1175 (regexp-quote mail-header-separator))
1177 (narrow-to-region (point-min) (match-beginning 0)))
1178 ;; highlight only when header is not too-big.
1179 (when (or (null wl-highlight-max-header-size)
1180 (< (point) wl-highlight-max-header-size))
1182 (while (and (not body-only)
1184 (if (looking-at "^[^ \t\n:]+[ \t]*:")
1186 (put-text-property (match-beginning 0) (match-end 0)
1187 'face 'wl-highlight-message-headers)
1188 (setq p (match-end 0))
1189 (setq hend (save-excursion (std11-field-end end)))
1191 (let ((regexp-alist wl-highlight-message-header-alist))
1193 (when (save-match-data
1194 (looking-at (caar regexp-alist)))
1195 (put-text-property p hend 'face
1196 (cdar regexp-alist))
1198 (setq regexp-alist (cdr regexp-alist)))
1199 (throw 'match nil)))
1201 p hend 'face 'wl-highlight-message-header-contents))
1203 ;; ignore non-header field name lines
1204 (forward-line 1)))))
1205 (let (prefix prefix-face-alist pair end)
1208 ((looking-at mail-header-separator)
1209 (put-text-property (match-beginning 0) (match-end 0)
1210 'face 'wl-highlight-header-separator-face)
1211 (goto-char (match-end 0)))
1212 ((null wl-highlight-force-citation-header-regexp)
1214 ((looking-at wl-highlight-force-citation-header-regexp)
1215 (setq current 'wl-highlight-message-citation-header)
1216 (setq end (match-end 0)))
1217 ((null wl-highlight-citation-prefix-regexp)
1219 ((looking-at wl-highlight-citation-prefix-regexp)
1220 (setq prefix (buffer-substring (point)
1222 (setq pair (assoc prefix prefix-face-alist))
1224 (setq prefix-face-alist
1225 (append prefix-face-alist
1231 (% (length prefix-face-alist)
1233 wl-highlight-citation-face-list))
1234 wl-highlight-citation-face-list)))))))
1235 (unless wl-highlight-highlight-citation-too
1236 (goto-char (match-end 0)))
1237 (setq current (cdr pair)))
1238 ((null wl-highlight-citation-header-regexp)
1240 ((looking-at wl-highlight-citation-header-regexp)
1241 (setq current 'wl-highlight-message-citation-header)
1242 (setq end (match-end 0)))
1243 (t (setq current nil)))
1246 (forward-line 1) ; this is to put the \n in the face too
1248 ;;; ((inhibit-read-only t))
1249 (put-text-property p (or end (point))
1254 (run-hooks 'wl-highlight-message-hook))))))
1256 ;; highlight-mouse-line for folder mode
1258 (defun wl-highlight-folder-mouse-line ()
1260 (let* ((end (save-excursion (end-of-line) (point)))
1262 (re-search-forward "[^ ]" end t)
1264 (inhibit-read-only t))
1265 (put-text-property beg end 'mouse-face 'highlight)))
1268 (autoload 'elmo-flag-folder-referrer "elmo-flag")
1271 (product-provide (provide 'wl-highlight) (require 'wl-version))
1273 ;;; wl-highlight.el ends here