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
600 (:foreground "green"))
603 (:foreground "GreenYellow"))
606 (:foreground "blue2")))
607 "Face used for displaying demo."
610 (wl-defface wl-highlight-logo-face
614 (:foreground "cyan"))
617 (:foreground "SkyBlue"))
620 (:foreground "SteelBlue")))
621 "Face used for displaying demo."
624 (wl-defface wl-highlight-action-argument-face
627 (:foreground "pink"))
630 (:foreground "red")))
631 "Face used for displaying action argument."
632 :group 'wl-summary-faces
637 (wl-defface wl-highlight-message-cited-text-1
641 (:foreground "magenta"))
644 (:foreground "HotPink1"))
647 (:foreground "ForestGreen")))
648 "Face used for displaying quoted text from other messages."
649 :group 'wl-message-faces
652 (wl-defface wl-highlight-message-cited-text-2
656 (:foreground "blue"))
658 (:foreground "violet")))
659 "Face used for displaying quoted text from other messages."
660 :group 'wl-message-faces
663 (wl-defface wl-highlight-message-cited-text-3
667 (:foreground "cyan"))
669 (:foreground "orchid3")))
670 "Face used for displaying quoted text from other messages."
671 :group 'wl-message-faces
674 (wl-defface wl-highlight-message-cited-text-4
678 (:foreground "green"))
680 (:foreground "purple1")))
681 "Face used for displaying quoted text from other messages."
682 :group 'wl-message-faces
685 (wl-defface wl-highlight-message-cited-text-5
689 (:foreground "yellow"))
691 (:foreground "MediumPurple1")))
692 "Face used for displaying quoted text from other messages."
693 :group 'wl-message-faces
696 (wl-defface wl-highlight-message-cited-text-6
702 (:foreground "PaleVioletRed")))
703 "Face used for displaying quoted text from other messages."
704 :group 'wl-message-faces
707 (wl-defface wl-highlight-message-cited-text-7
711 (:foreground "magenta"))
713 (:foreground "LightPink")))
714 "Face used for displaying quoted text from other messages."
715 :group 'wl-message-faces
718 (wl-defface wl-highlight-message-cited-text-8
722 (:foreground "blue"))
724 (:foreground "salmon")))
725 "Face used for displaying quoted text from other messages."
726 :group 'wl-message-faces
729 (wl-defface wl-highlight-message-cited-text-9
733 (:foreground "cyan"))
735 (:foreground "SandyBrown")))
736 "Face used for displaying quoted text from other messages."
737 :group 'wl-message-faces
740 (wl-defface wl-highlight-message-cited-text-10
744 (:foreground "green"))
746 (:foreground "wheat")))
747 "Face used for displaying quoted text from other messages."
748 :group 'wl-message-faces
751 (defface wl-message-header-narrowing-face
752 '((((class color) (background light))
753 (:foreground "black" :background "dark khaki"))
754 (((class color) (background dark))
755 (:foreground "white" :background "dark goldenrod"))
757 "Face used for header narrowing for the message."
758 :group 'wl-message-faces
761 (defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
762 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
763 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
765 (defvar wl-highlight-citation-face-list
766 '(wl-highlight-message-cited-text-1
767 wl-highlight-message-cited-text-2
768 wl-highlight-message-cited-text-3
769 wl-highlight-message-cited-text-4
770 wl-highlight-message-cited-text-5
771 wl-highlight-message-cited-text-6
772 wl-highlight-message-cited-text-7
773 wl-highlight-message-cited-text-8
774 wl-highlight-message-cited-text-9
775 wl-highlight-message-cited-text-10))
777 (defmacro wl-delete-all-overlays ()
778 "Delete all momentary overlays."
779 '(let ((overlays (overlays-in (point-min) (point-max)))
781 (while (setq overlay (car overlays))
782 (if (overlay-get overlay 'wl-momentary-overlay)
783 (delete-overlay overlay))
784 (setq overlays (cdr overlays)))))
786 (defun wl-highlight-summary-displaying ()
788 (wl-delete-all-overlays)
795 (setq ov (make-overlay bol eol))
796 (overlay-put ov 'face 'wl-highlight-summary-displaying-face)
797 (overlay-put ov 'evaporate t)
798 (overlay-put ov 'wl-momentary-overlay t))))
800 (defun wl-highlight-folder-group-line (numbers)
806 (let ((text-face (cond ((looking-at wl-highlight-folder-opened-regexp)
807 'wl-highlight-folder-opened-face)
808 ((looking-at wl-highlight-folder-closed-regexp)
809 'wl-highlight-folder-closed-face))))
810 (if (and wl-highlight-folder-by-numbers
811 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" eol t))
812 (let* ((unsync (nth 0 numbers))
813 (unread (nth 1 numbers))
814 (face (cond ((and unsync (zerop unsync))
815 (if (and unread (> unread 0))
816 'wl-highlight-folder-unread-face
817 'wl-highlight-folder-zero-face))
819 (>= unsync wl-folder-many-unsync-threshold))
820 'wl-highlight-folder-many-face)
822 'wl-highlight-folder-few-face))))
823 (if (numberp wl-highlight-folder-by-numbers)
825 (put-text-property bol (match-beginning 0) 'face text-face)
826 (put-text-property (match-beginning 0) (match-end 0)
828 ;; Remove previous face.
829 (put-text-property bol (match-end 0) 'face nil)
830 (put-text-property bol (match-end 0) 'face face)))
831 (put-text-property bol eol 'face text-face)))))
833 (defsubst wl-highlight-summary-line-face-spec (flags temp-mark indent)
834 "Return a cons cell of (face . argument)."
836 (if (setq action (assoc temp-mark wl-summary-mark-action-list))
837 (cons (nth 5 action) (nth 2 action))
839 ((and (string= temp-mark wl-summary-score-over-mark)
840 (or (memq 'new flags) (memq 'unread flags)))
841 '(wl-highlight-summary-high-unread-face))
842 ((and (string= temp-mark wl-summary-score-below-mark)
843 (or (memq 'new flags) (memq 'unread flags)))
844 '(wl-highlight-summary-low-unread-face))
845 ((let ((priorities wl-summary-flag-priority-list)
847 (while (and (null result) priorities)
848 (when (memq (car priorities) flags)
850 (case (car priorities)
852 '(wl-highlight-summary-new-face))
854 '(wl-highlight-summary-important-face))
856 '(wl-highlight-summary-answered-face))
858 '(wl-highlight-summary-unread-face)))))
859 (setq priorities (cdr priorities)))
861 ((string= temp-mark wl-summary-score-below-mark)
862 '(wl-highlight-summary-low-read-face))
863 ((string= temp-mark wl-summary-score-over-mark)
864 '(wl-highlight-summary-high-read-face))
866 '(wl-highlight-summary-normal-face)
867 '(wl-highlight-summary-thread-top-face)))))))
869 (defun wl-highlight-summary-line-flag-folder (number beg end &optional string)
870 ;; help-echo for flag folder.
873 (when (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
876 (elmo-flag-folder-referrer wl-summary-buffer-elmo-folder
879 (put-text-property beg end 'help-echo
880 (concat "The message exists in "
883 (concat (car pair) "/"
889 (defun wl-highlight-summary-line-string (number line flags temp-mark indent)
890 (let ((fsymbol (car (wl-highlight-summary-line-face-spec
893 (> (length indent) 0)))))
894 (put-text-property 0 (length line) 'face fsymbol line))
895 (when wl-use-highlight-mouse-line
896 (put-text-property 0 (length line) 'mouse-face 'highlight line))
897 (when wl-use-flag-folder-help-echo
898 (wl-highlight-summary-line-flag-folder number 0 (length line) line)))
900 (defun wl-highlight-summary-current-line (&optional number flags)
903 (let ((inhibit-read-only t)
904 (case-fold-search nil)
905 (deactivate-mark nil)
906 (number (or number (wl-summary-message-number)))
912 (setq spec (wl-highlight-summary-line-face-spec
914 (elmo-message-flags wl-summary-buffer-elmo-folder
916 (wl-summary-temp-mark number)
917 (wl-thread-entity-get-parent-entity
918 (wl-thread-get-entity number))))
920 (put-text-property bol eol 'face (car spec)))
922 (put-text-property (next-single-property-change
923 (next-single-property-change
924 bol 'wl-summary-action-argument
926 'wl-summary-action-argument nil eol)
929 'wl-highlight-action-argument-face))
930 (when wl-use-highlight-mouse-line
931 (put-text-property bol eol 'mouse-face 'highlight))
932 (when wl-use-flag-folder-help-echo
933 (wl-highlight-summary-line-flag-folder number bol eol))
935 (wl-dnd-set-drag-starter bol eol)))))
937 (defun wl-highlight-folder (start end)
938 "Highlight folder between start and end.
940 wl-highlight-folder-unknown-face unread messages
941 wl-highlight-folder-zero-face folder needs no sync
942 wl-highlight-folder-few-face folder contains few unsync messages
943 wl-highlight-folder-many-face folder contains many unsync messages
944 wl-highlight-folder-opened-face opened group folder
945 wl-highlight-folder-closed-face closed group folder
948 wl-highlight-folder-opened-regexp matches opened group folder
949 wl-highlight-folder-closed-regexp matches closed group folder
953 (let ((s start)) (setq start end end s)))
954 (let* ((lines (count-lines start end))
960 (narrow-to-region start end)
964 (wl-highlight-folder-current-line)
965 (forward-line 1)))))))
967 (defun wl-highlight-folder-path (folder-path)
968 "Highlight current folder path...overlay"
970 (wl-delete-all-overlays)
971 (let ((fp folder-path) ov)
972 (goto-char (point-min))
976 (or (looking-at "^[ ]*\\[[\\+-]\\]\\(.+\\):.*\n")
977 (looking-at "^[ ]*\\([^ \\[].+\\):.*\n"))
979 (get-text-property (point) 'wl-folder-entity-id)
982 (setq ov (make-overlay
985 (setq wl-folder-buffer-cur-point (point))
986 (overlay-put ov 'face 'wl-highlight-folder-path-face)
987 (overlay-put ov 'evaporate t)
988 (overlay-put ov 'wl-momentary-overlay t))
991 (defun wl-highlight-action-argument-string (string)
992 (put-text-property 0 (length string) 'face
993 'wl-highlight-action-argument-face
996 (defun wl-highlight-summary-all ()
999 (wl-highlight-summary (point-min)(point-max)))
1001 (defun wl-highlight-summary (start end &optional lazy)
1002 "Highlight summary between start and end.
1004 wl-highlight-summary-unread-face unread messages
1005 wl-highlight-summary-important-face important messages
1006 wl-highlight-summary-deleted-face messages mark as deleted
1007 wl-highlight-summary-refiled-face messages mark as refiled
1008 wl-highlight-summary-copied-face messages mark as copied
1009 wl-highlight-summary-new-face new messages"
1011 (let ((s start)) (setq start end end s)))
1012 (let (lines too-big gc-message e p hend i percent)
1014 (unless wl-summary-lazy-highlight
1015 (setq lines (count-lines start end)
1016 too-big (and wl-highlight-max-summary-lines
1017 (> lines wl-highlight-max-summary-lines))))
1020 (while (and (not (eobp))
1022 (when (or (not lazy)
1023 (null (get-text-property (point) 'face)))
1024 (wl-highlight-summary-current-line))
1026 (unless wl-summary-lazy-highlight
1027 (message "Highlighting...done")))))
1029 (defun wl-highlight-summary-window (&optional win beg)
1030 "Highlight summary window.
1031 This function is defined for `window-scroll-functions'"
1032 (when wl-summary-highlight
1033 (with-current-buffer (window-buffer win)
1034 (when (eq major-mode 'wl-summary-mode)
1035 (let ((start (window-start win))
1036 (end (condition-case nil
1037 (window-end win t) ;; old emacsen doesn't support 2nd arg.
1038 (error (window-end win)))))
1039 (wl-highlight-summary start
1042 (set-buffer-modified-p nil)))))
1044 (defun wl-highlight-headers (&optional for-draft)
1045 (let ((beg (point-min))
1046 (end (or (save-excursion (re-search-forward "^$" nil t)
1049 (wl-highlight-message beg end nil)
1051 (when wl-highlight-x-face-function
1052 (funcall wl-highlight-x-face-function)))
1053 (run-hooks 'wl-highlight-headers-hook)))
1055 (defun wl-highlight-body-all ()
1056 (wl-highlight-message (point-min) (point-max) t t))
1058 (defun wl-highlight-body ()
1059 (let ((beg (or (save-excursion (goto-char (point-min))
1060 (re-search-forward "^$" nil t))
1063 (wl-highlight-message beg end t)))
1065 (defun wl-highlight-body-region (beg end)
1066 (wl-highlight-message beg end t t))
1068 (defun wl-highlight-signature-search-simple (beg end)
1069 "Search signature area in the body message between BEG and END.
1070 Returns start point of signature."
1073 (if (re-search-backward "\n--+ *\n" beg t)
1074 (if (eq (char-after (point)) ?\n)
1079 (defun wl-highlight-signature-search (beg end)
1080 "Search signature area in the body message between BEG and END.
1081 Returns start point of signature."
1085 ;; look for legal signature separator (check at first for fasten)
1086 (re-search-backward "\n-- \n" beg t)
1088 ;; look for dual separator
1091 (re-search-backward "^[^A-Za-z0-9> \t\n]+ *$" beg t)
1092 (> (- (match-end 0) (match-beginning 0)) 10);; "10" is a magic number.
1095 (regexp-quote (buffer-substring (match-beginning 0) (match-end 0)))
1098 ;; look for user specified signature-separator
1099 (if (stringp wl-highlight-signature-separator)
1100 (re-search-backward wl-highlight-signature-separator nil t);; case one string
1101 (let ((sep wl-highlight-signature-separator)) ;; case list
1103 (not (re-search-backward (car sep) beg t)))
1104 (setq sep (cdr sep)))
1105 (point))) ;; if no separator found, returns end.
1108 (defun wl-highlight-message (start end hack-sig &optional body-only)
1109 "Highlight message headers between start and end.
1111 wl-highlight-message-headers the part before the colon
1112 wl-highlight-message-header-contents the part after the colon
1113 wl-highlight-message-important-header-contents contents of \"special\"
1115 wl-highlight-message-important-header-contents2 contents of \"special\"
1117 wl-highlight-message-unimportant-header-contents contents of unimportant
1119 wl-highlight-message-cited-text quoted text from other
1121 wl-highlight-message-citation-header header of quoted texts
1122 wl-highlight-message-signature signature
1125 wl-highlight-important-header-regexp what makes a \"special\" header
1126 wl-highlight-important-header2-regexp what makes a \"special\" header
1127 wl-highlight-unimportant-header-regexp what makes a \"special\" header
1128 wl-highlight-citation-prefix-regexp matches lines of quoted text
1129 wl-highlight-citation-header-regexp matches headers for quoted text
1131 If HACK-SIG is true,then we search backward from END for something that
1132 looks like the beginning of a signature block, and don't consider that a
1133 part of the message (this is because signatures are often incorrectly
1134 interpreted as cited text.)"
1136 (let ((s start)) (setq start end end s)))
1137 (let ((too-big (and wl-highlight-max-message-size
1139 wl-highlight-max-message-size)))
1147 ;; take off signature
1148 (if (and hack-sig (not too-big))
1149 (setq end (funcall wl-highlight-signature-search-function
1150 (- end wl-max-signature-size) end)))
1152 (not (eq end real-end)))
1153 (put-text-property end (point-max)
1154 'face 'wl-highlight-message-signature))
1155 (narrow-to-region start end)
1157 ;; narrow down to just the headers...
1159 ;; If this search fails then the narrowing performed above
1161 (if (re-search-forward (format
1163 (regexp-quote mail-header-separator))
1165 (narrow-to-region (point-min) (match-beginning 0)))
1166 ;; highlight only when header is not too-big.
1167 (when (or (null wl-highlight-max-header-size)
1168 (< (point) wl-highlight-max-header-size))
1170 (while (and (not body-only)
1172 (if (looking-at "^[^ \t\n:]+[ \t]*:")
1174 (put-text-property (match-beginning 0) (match-end 0)
1175 'face 'wl-highlight-message-headers)
1176 (setq p (match-end 0))
1177 (setq hend (save-excursion (std11-field-end end)))
1179 (let ((regexp-alist wl-highlight-message-header-alist))
1181 (when (save-match-data
1182 (looking-at (caar regexp-alist)))
1183 (put-text-property p hend 'face
1184 (cdar regexp-alist))
1186 (setq regexp-alist (cdr regexp-alist)))
1187 (throw 'match nil)))
1189 p hend 'face 'wl-highlight-message-header-contents))
1191 ;; ignore non-header field name lines
1192 (forward-line 1)))))
1193 (let (prefix prefix-face-alist pair end)
1196 ((looking-at mail-header-separator)
1197 (put-text-property (match-beginning 0) (match-end 0)
1198 'face 'wl-highlight-header-separator-face)
1199 (goto-char (match-end 0)))
1200 ((null wl-highlight-force-citation-header-regexp)
1202 ((looking-at wl-highlight-force-citation-header-regexp)
1203 (setq current 'wl-highlight-message-citation-header)
1204 (setq end (match-end 0)))
1205 ((null wl-highlight-citation-prefix-regexp)
1207 ((looking-at wl-highlight-citation-prefix-regexp)
1208 (setq prefix (buffer-substring (point)
1210 (setq pair (assoc prefix prefix-face-alist))
1212 (setq prefix-face-alist
1213 (append prefix-face-alist
1219 (% (length prefix-face-alist)
1221 wl-highlight-citation-face-list))
1222 wl-highlight-citation-face-list)))))))
1223 (unless wl-highlight-highlight-citation-too
1224 (goto-char (match-end 0)))
1225 (setq current (cdr pair)))
1226 ((null wl-highlight-citation-header-regexp)
1228 ((looking-at wl-highlight-citation-header-regexp)
1229 (setq current 'wl-highlight-message-citation-header)
1230 (setq end (match-end 0)))
1231 (t (setq current nil)))
1234 (forward-line 1) ; this is to put the \n in the face too
1236 ;;; ((inhibit-read-only t))
1237 (put-text-property p (or end (point))
1242 (run-hooks 'wl-highlight-message-hook))))))
1244 ;; highlight-mouse-line for folder mode
1246 (defun wl-highlight-folder-mouse-line ()
1248 (let* ((end (save-excursion (end-of-line) (point)))
1250 (re-search-forward "[^ ]" end t)
1252 (inhibit-read-only t))
1253 (put-text-property beg end 'mouse-face 'highlight)))
1256 (autoload 'elmo-flag-folder-referrer "elmo-flag")
1259 (product-provide (provide 'wl-highlight) (require 'wl-version))
1261 ;;; wl-highlight.el ends here