1 ;;; wl-highlight.el --- Hilight modules for Wanderlust.
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
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-new-face
199 (:foreground "tomato"))
202 (:foreground "tomato")))
203 "Face used for displaying new messages."
204 :group 'wl-summary-faces
207 (wl-defface wl-highlight-summary-displaying-face
209 (:underline t :bold t)))
210 "Face used for displaying message."
211 :group 'wl-summary-faces
214 (wl-defface wl-highlight-thread-indent-face
216 (:foreground "gray40")))
217 "Face used for displaying indented thread."
218 :group 'wl-summary-faces
221 ;; unimportant messages
223 (wl-defface wl-highlight-summary-unread-face
227 (:foreground "cyan"))
230 (:foreground "LightSkyBlue"))
233 (:foreground "RoyalBlue")))
234 "Face used for displaying unread messages."
235 :group 'wl-summary-faces
238 (wl-defface wl-highlight-summary-disposed-face
242 (:foreground "blue"))
245 (:foreground "gray"))
248 (:foreground "DarkKhaki")))
249 "Face used for displaying messages mark as disposed."
250 :group 'wl-summary-faces
253 (wl-defface wl-highlight-summary-deleted-face
257 (:foreground "blue"))
260 (:foreground "SteelBlue"))
263 (:foreground "RoyalBlue4")))
264 "Face used for displaying messages mark as deleted."
265 :group 'wl-summary-faces
268 (wl-defface wl-highlight-summary-prefetch-face
272 (:foreground "Green"))
275 (:foreground "DeepSkyBlue"))
278 (:foreground "brown")))
279 "Face used for displaying messages mark as deleted."
280 :group 'wl-summary-faces
283 (wl-defface wl-highlight-summary-resend-face
287 (:foreground "Yellow"))
290 (:foreground "orange3"))
293 (:foreground "orange3")))
294 "Face used for displaying messages mark as resend."
295 :group 'wl-summary-faces
298 (wl-defface wl-highlight-summary-refiled-face
302 (:foreground "blue"))
305 (:foreground "blue"))
308 (:foreground "firebrick")))
309 "Face used for displaying messages mark as refiled."
310 :group 'wl-summary-faces
313 (wl-defface wl-highlight-summary-copied-face
317 (:foreground "blue"))
320 (:foreground "cyan"))
323 (:foreground "blue")))
324 "Face used for displaying messages mark as copied."
325 :group 'wl-summary-faces
329 (wl-defface wl-highlight-summary-answered-face
332 (:foreground "yellow"))
335 (:foreground "khaki"))
338 (:foreground "khaki4")))
339 "Face used for displaying answered messages."
340 :group 'wl-summary-faces
344 (wl-defface wl-highlight-summary-forwarded-face
347 (:foreground "yellow"))
350 (:foreground "DarkOliveGreen2"))
353 (:foreground "DarkOliveGreen4")))
354 "Face used for displaying forwarded messages."
355 :group 'wl-summary-faces
358 (wl-defface wl-summary-persistent-mark-face
360 (:foreground "blue"))
363 (:foreground "SeaGreen4"))
366 (:foreground "SeaGreen1")))
367 "Dafault face used for displaying messages with persistent mark."
368 :group 'wl-summary-faces
372 (wl-defface wl-highlight-summary-temp-face
376 (:foreground "gold"))
378 (:foreground "HotPink1")))
379 "Face used for displaying messages mark as temp."
380 :group 'wl-summary-faces
383 (wl-defface wl-highlight-summary-target-face
387 (:foreground "gold"))
389 (:foreground "HotPink1")))
390 "Face used for displaying messages mark as target."
391 :group 'wl-summary-faces
394 (wl-defface wl-highlight-summary-low-read-face
398 (:foreground "yellow" :italic t))
401 (:foreground "PaleGreen" :italic t))
404 (:foreground "Green3" :italic t)))
405 "Face used for displaying low interest read messages."
406 :group 'wl-summary-faces
409 (wl-defface wl-highlight-summary-high-read-face
415 (:foreground "PaleGreen" :bold t))
418 (:foreground "SeaGreen" :bold t)))
419 "Face used for displaying high interest read messages."
420 :group 'wl-summary-faces
423 (wl-defface wl-highlight-summary-low-unread-face
427 (:foreground "cyan" :italic t))
430 (:foreground "LightSkyBlue" :italic t))
433 (:foreground "RoyalBlue" :italic t)))
434 "Face used for displaying low interest unread messages."
435 :group 'wl-summary-faces
438 (wl-defface wl-highlight-summary-high-unread-face
441 (:foreground "red" :bold t))
444 (:foreground "tomato" :bold t))
447 (:foreground "tomato" :bold t)))
448 "Face used for displaying high interest unread messages."
449 :group 'wl-summary-faces
454 (wl-defface wl-highlight-summary-thread-top-face
458 (:foreground "green"))
461 (:foreground "GreenYellow"))
464 (:foreground "green4")))
465 "Face used for displaying top thread message."
466 :group 'wl-summary-faces
469 (wl-defface wl-highlight-summary-normal-face
473 (:foreground "yellow"))
476 (:foreground "PaleGreen"))
479 (:foreground "SeaGreen")))
480 "Face used for displaying normal message."
481 :group 'wl-summary-faces
486 (wl-defface wl-highlight-folder-unknown-face
490 (:foreground "cyan"))
493 (:foreground "pink"))
496 (:foreground "RoyalBlue")))
497 "Face used for displaying unread folder."
498 :group 'wl-folder-faces
501 (wl-defface wl-highlight-folder-killed-face
505 (:foreground "gray"))
507 (:foreground "gray50")))
508 "Face used for displaying killed folder."
509 :group 'wl-folder-faces
512 (wl-defface wl-highlight-folder-zero-face
516 (:foreground "green"))
519 (:foreground "SkyBlue"))
522 (:foreground "BlueViolet")))
523 "Face used for displaying folder needs no sync."
524 :group 'wl-folder-faces
527 (wl-defface wl-highlight-folder-few-face
531 (:foreground "yellow"))
534 (:foreground "orange"))
537 (:foreground "OrangeRed3")))
538 "Face used for displaying folder contains few unsync messages."
539 :group 'wl-folder-faces
542 (wl-defface wl-highlight-folder-many-face
549 (:foreground "HotPink1"))
552 (:foreground "tomato")))
553 "Face used for displaying folder contains many unsync messages."
554 :group 'wl-folder-faces
557 (wl-defface wl-highlight-folder-unread-face
561 (:foreground "magenta"))
564 (:foreground "gold"))
567 (:foreground "MediumVioletRed")))
568 "Face used for displaying unread folder."
569 :group 'wl-folder-faces
572 (wl-defface wl-highlight-folder-opened-face
576 (:foreground "blue"))
579 (:foreground "PaleGreen"))
582 (:foreground "ForestGreen")))
583 "Face used for displaying opened group folder."
584 :group 'wl-folder-faces
587 (wl-defface wl-highlight-folder-closed-face
591 (:foreground "cyan"))
594 (:foreground "GreenYellow"))
597 (:foreground "DarkOliveGreen4")))
598 "Face used for displaying closed group folder."
599 :group 'wl-folder-faces
602 (wl-defface wl-highlight-folder-path-face
604 (:bold t :underline t)))
605 "Face used for displaying path."
606 :group 'wl-folder-faces
609 (wl-defface wl-highlight-demo-face
611 (:foreground "green"))
614 (:foreground "#006600" :background "#d9ffd9"))
617 (:foreground "#d9ffd9" :background "#004400")))
618 "Face used for displaying demo."
621 (wl-defface wl-highlight-logo-face
624 (:foreground "cyan"))
627 (:foreground "SteelBlue" :background "#d9ffd9"))
630 (:foreground "SkyBlue" :background "#004400")))
631 "Face used for displaying demo."
634 (wl-defface wl-highlight-action-argument-face
637 (:foreground "pink"))
640 (:foreground "red")))
641 "Face used for displaying action argument."
642 :group 'wl-summary-faces
647 (wl-defface wl-highlight-message-cited-text-1
651 (:foreground "magenta"))
654 (:foreground "HotPink1"))
657 (:foreground "ForestGreen")))
658 "Face used for displaying quoted text from other messages."
659 :group 'wl-message-faces
662 (wl-defface wl-highlight-message-cited-text-2
666 (:foreground "blue"))
668 (:foreground "violet")))
669 "Face used for displaying quoted text from other messages."
670 :group 'wl-message-faces
673 (wl-defface wl-highlight-message-cited-text-3
677 (:foreground "cyan"))
679 (:foreground "orchid3")))
680 "Face used for displaying quoted text from other messages."
681 :group 'wl-message-faces
684 (wl-defface wl-highlight-message-cited-text-4
688 (:foreground "green"))
690 (:foreground "purple1")))
691 "Face used for displaying quoted text from other messages."
692 :group 'wl-message-faces
695 (wl-defface wl-highlight-message-cited-text-5
699 (:foreground "yellow"))
701 (:foreground "MediumPurple1")))
702 "Face used for displaying quoted text from other messages."
703 :group 'wl-message-faces
706 (wl-defface wl-highlight-message-cited-text-6
712 (:foreground "PaleVioletRed")))
713 "Face used for displaying quoted text from other messages."
714 :group 'wl-message-faces
717 (wl-defface wl-highlight-message-cited-text-7
721 (:foreground "magenta"))
723 (:foreground "LightPink")))
724 "Face used for displaying quoted text from other messages."
725 :group 'wl-message-faces
728 (wl-defface wl-highlight-message-cited-text-8
732 (:foreground "blue"))
734 (:foreground "salmon")))
735 "Face used for displaying quoted text from other messages."
736 :group 'wl-message-faces
739 (wl-defface wl-highlight-message-cited-text-9
743 (:foreground "cyan"))
745 (:foreground "SandyBrown")))
746 "Face used for displaying quoted text from other messages."
747 :group 'wl-message-faces
750 (wl-defface wl-highlight-message-cited-text-10
754 (:foreground "green"))
756 (:foreground "wheat")))
757 "Face used for displaying quoted text from other messages."
758 :group 'wl-message-faces
761 (defface wl-message-header-narrowing-face
762 '((((class color) (background light))
763 (:foreground "black" :background "dark khaki"))
764 (((class color) (background dark))
765 (:foreground "white" :background "dark goldenrod"))
767 "Face used for header narrowing for the message."
768 :group 'wl-message-faces
771 (defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
772 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
773 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
775 (defvar wl-highlight-citation-face-list
776 '(wl-highlight-message-cited-text-1
777 wl-highlight-message-cited-text-2
778 wl-highlight-message-cited-text-3
779 wl-highlight-message-cited-text-4
780 wl-highlight-message-cited-text-5
781 wl-highlight-message-cited-text-6
782 wl-highlight-message-cited-text-7
783 wl-highlight-message-cited-text-8
784 wl-highlight-message-cited-text-9
785 wl-highlight-message-cited-text-10))
787 (defmacro wl-delete-all-overlays ()
788 "Delete all momentary overlays."
789 '(let ((overlays (overlays-in (point-min) (point-max)))
791 (while (setq overlay (car overlays))
792 (if (overlay-get overlay 'wl-momentary-overlay)
793 (delete-overlay overlay))
794 (setq overlays (cdr overlays)))))
796 (defun wl-highlight-summary-displaying ()
798 (wl-delete-all-overlays)
805 (setq ov (make-overlay bol eol))
806 (overlay-put ov 'face 'wl-highlight-summary-displaying-face)
807 (overlay-put ov 'evaporate t)
808 (overlay-put ov 'wl-momentary-overlay t))))
810 (defun wl-highlight-folder-group-line (numbers)
816 (let ((text-face (cond ((looking-at wl-highlight-folder-opened-regexp)
817 'wl-highlight-folder-opened-face)
818 ((looking-at wl-highlight-folder-closed-regexp)
819 'wl-highlight-folder-closed-face))))
820 (if (and wl-highlight-folder-by-numbers
821 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" eol t))
822 (let* ((unsync (nth 0 numbers))
823 (unread (nth 1 numbers))
824 (face (cond ((and unsync (zerop unsync))
825 (if (and unread (> unread 0))
826 'wl-highlight-folder-unread-face
827 'wl-highlight-folder-zero-face))
829 (>= unsync wl-folder-many-unsync-threshold))
830 'wl-highlight-folder-many-face)
832 'wl-highlight-folder-few-face))))
833 (if (numberp wl-highlight-folder-by-numbers)
835 (put-text-property bol (match-beginning 0) 'face text-face)
836 (put-text-property (match-beginning 0) (match-end 0)
838 ;; Remove previous face.
839 (put-text-property bol (match-end 0) 'face nil)
840 (put-text-property bol (match-end 0) 'face face)))
841 (put-text-property bol eol 'face text-face)))))
843 (defsubst wl-highlight-summary-line-face-spec (flags temp-mark indent)
844 "Return a cons cell of (face . argument)."
846 (if (setq action (assoc temp-mark wl-summary-mark-action-list))
847 (cons (nth 5 action) (nth 2 action))
849 ((and (string= temp-mark wl-summary-score-over-mark)
850 (or (memq 'new flags) (memq 'unread flags)))
851 '(wl-highlight-summary-high-unread-face))
852 ((and (string= temp-mark wl-summary-score-below-mark)
853 (or (memq 'new flags) (memq 'unread flags)))
854 '(wl-highlight-summary-low-unread-face))
855 ((let ((priorities wl-summary-persistent-mark-priority-list)
856 (fl wl-summary-flag-alist)
857 face result global-flags)
858 (while (and (null result) priorities)
859 (if (and (eq (car priorities) 'flag)
861 (elmo-get-global-flags flags 'ignore-preserved)))
863 (when (memq (car (car fl)) global-flags)
868 "wl-highlight-summary-%s-flag-face"
870 (when (find-face face)
874 (when (memq (car priorities) flags)
878 "wl-highlight-summary-%s-face"
882 (list 'wl-summary-persistent-mark-face))))))
883 (setq priorities (cdr priorities)))
885 ((string= temp-mark wl-summary-score-below-mark)
886 '(wl-highlight-summary-low-read-face))
887 ((string= temp-mark wl-summary-score-over-mark)
888 '(wl-highlight-summary-high-read-face))
890 '(wl-highlight-summary-normal-face)
891 '(wl-highlight-summary-thread-top-face)))))))
893 (autoload 'elmo-flag-folder-referrer "elmo-flag")
894 (defun wl-highlight-flag-folder-help-echo (folder number)
895 (let ((referer (elmo-flag-folder-referrer folder number)))
896 (concat "The message exists in "
899 (concat (car pair) "/"
904 (defun wl-highlight-summary-line-help-echo (number beg end &optional string)
905 (let ((type (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
907 (when (setq handler (cadr (assq type wl-highlight-summary-line-help-echo-alist)))
909 (funcall handler wl-summary-buffer-elmo-folder number))
911 (put-text-property beg end 'help-echo
915 (defun wl-highlight-summary-line-string (number line flags temp-mark indent)
916 (let ((fsymbol (car (wl-highlight-summary-line-face-spec
919 (> (length indent) 0)))))
920 (put-text-property 0 (length line) 'face fsymbol line))
921 (when wl-use-highlight-mouse-line
922 (put-text-property 0 (length line) 'mouse-face 'highlight line))
923 (when wl-highlight-summary-line-help-echo-alist
924 (wl-highlight-summary-line-help-echo number 0 (length line) line)))
926 (defun wl-highlight-summary-current-line (&optional number flags)
929 (let ((inhibit-read-only t)
930 (case-fold-search nil)
931 (deactivate-mark nil)
932 (number (or number (wl-summary-message-number)))
939 (setq spec (wl-highlight-summary-line-face-spec
941 (elmo-message-flags wl-summary-buffer-elmo-folder
943 (wl-summary-temp-mark number)
944 (wl-thread-entity-get-parent-entity
945 (wl-thread-get-entity number))))
947 (put-text-property bol eol 'face (car spec)))
949 (put-text-property (next-single-property-change
950 (next-single-property-change
951 bol 'wl-summary-action-argument
953 'wl-summary-action-argument nil eol)
956 'wl-highlight-action-argument-face))
957 (when wl-use-highlight-mouse-line
958 (put-text-property bol eol 'mouse-face 'highlight))
959 (when wl-highlight-summary-line-help-echo-alist
960 (wl-highlight-summary-line-help-echo number bol eol))
962 (wl-dnd-set-drag-starter bol eol))))))
964 (defun wl-highlight-folder (start end)
965 "Highlight folder between start and end.
967 wl-highlight-folder-unknown-face unread messages
968 wl-highlight-folder-zero-face folder needs no sync
969 wl-highlight-folder-few-face folder contains few unsync messages
970 wl-highlight-folder-many-face folder contains many unsync messages
971 wl-highlight-folder-opened-face opened group folder
972 wl-highlight-folder-closed-face closed group folder
975 wl-highlight-folder-opened-regexp matches opened group folder
976 wl-highlight-folder-closed-regexp matches closed group folder
980 (let ((s start)) (setq start end end s)))
981 (let* ((lines (count-lines start end))
987 (narrow-to-region start end)
991 (wl-highlight-folder-current-line)
992 (forward-line 1)))))))
994 (defun wl-highlight-folder-path (folder-path)
995 "Highlight current folder path...overlay"
997 (wl-delete-all-overlays)
998 (let ((fp folder-path) ov)
999 (goto-char (point-min))
1003 (or (looking-at "^[ ]*\\[[\\+-]\\]\\(.+\\):.*\n")
1004 (looking-at "^[ ]*\\([^ \\[].+\\):.*\n"))
1006 (get-text-property (point) 'wl-folder-entity-id)
1009 (setq ov (make-overlay
1012 (setq wl-folder-buffer-cur-point (point))
1013 (overlay-put ov 'face 'wl-highlight-folder-path-face)
1014 (overlay-put ov 'evaporate t)
1015 (overlay-put ov 'wl-momentary-overlay t))
1016 (forward-line 1)))))
1018 (defun wl-highlight-action-argument-string (string)
1019 (put-text-property 0 (length string) 'face
1020 'wl-highlight-action-argument-face
1023 (defun wl-highlight-summary-all ()
1026 (wl-highlight-summary (point-min)(point-max)))
1028 (defun wl-highlight-summary (start end &optional lazy)
1029 "Highlight summary between start and end.
1031 wl-highlight-summary-unread-face unread messages
1032 wl-highlight-summary-deleted-face messages mark as deleted
1033 wl-highlight-summary-refiled-face messages mark as refiled
1034 wl-highlight-summary-copied-face messages mark as copied
1035 wl-highlight-summary-new-face new messages
1036 wl-highlight-summary-*-flag-face flagged messages"
1038 (let ((s start)) (setq start end end s)))
1039 (let (lines too-big gc-message e p hend i percent)
1041 (unless wl-summary-lazy-highlight
1042 (setq lines (count-lines start end)
1043 too-big (and wl-highlight-max-summary-lines
1044 (> lines wl-highlight-max-summary-lines))))
1047 (while (and (not (eobp))
1049 (when (or (not lazy)
1050 (null (get-text-property (point) 'face)))
1051 (wl-highlight-summary-current-line))
1053 (unless wl-summary-lazy-highlight
1054 (message "Highlighting...done")))))
1056 (defun wl-highlight-summary-window (&optional win beg)
1057 "Highlight summary window.
1058 This function is defined for `window-scroll-functions'"
1059 (when wl-summary-highlight
1060 (with-current-buffer (window-buffer win)
1061 (when (eq major-mode 'wl-summary-mode)
1062 (let ((start (window-start win))
1063 (end (condition-case nil
1064 (window-end win t) ;; old emacsen doesn't support 2nd arg.
1065 (error (window-end win)))))
1066 (wl-highlight-summary start
1069 (set-buffer-modified-p nil)))))
1071 (defun wl-highlight-headers (&optional for-draft)
1072 (let ((beg (point-min))
1073 (end (or (save-excursion (re-search-forward "^$" nil t)
1076 (wl-highlight-message beg end nil)
1078 (when wl-highlight-x-face-function
1079 (funcall wl-highlight-x-face-function)))
1080 (run-hooks 'wl-highlight-headers-hook)))
1082 (defun wl-highlight-body-all ()
1083 (wl-highlight-message (point-min) (point-max) t t))
1085 (defun wl-highlight-body ()
1086 (let ((beg (or (save-excursion (goto-char (point-min))
1087 (re-search-forward "^$" nil t))
1090 (wl-highlight-message beg end t)))
1092 (defun wl-highlight-body-region (beg end)
1093 (wl-highlight-message beg end t t))
1095 (defun wl-highlight-signature-search-simple (beg end)
1096 "Search signature area in the body message between BEG and END.
1097 Returns start point of signature."
1100 (if (re-search-backward "\n--+ *\n" beg t)
1101 (if (eq (char-after (point)) ?\n)
1106 (defun wl-highlight-signature-search (beg end)
1107 "Search signature area in the body message between BEG and END.
1108 Returns start point of signature."
1112 ;; look for legal signature separator (check at first for fasten)
1113 (search-backward "\n-- \n" beg t)
1115 ;; look for dual separator
1119 (and (re-search-backward "^[^A-Za-z0-9> \t\n]+ *$" beg t)
1120 ;; `10' is a magic number.
1121 (> (- (match-end 0) (match-beginning 0)) 10)
1122 (setq separator (buffer-substring (match-beginning 0)
1124 ;; We should not use `re-search-backward' for a long word
1125 ;; since it is possible to crash XEmacs because of a bug.
1126 (if (search-backward (concat "\n" separator "\n") beg t)
1128 (and (search-backward (concat separator "\n") beg t)
1133 ;; look for user specified signature-separator
1134 (if (stringp wl-highlight-signature-separator)
1135 (re-search-backward wl-highlight-signature-separator nil t);; case one string
1136 (let ((sep wl-highlight-signature-separator)) ;; case list
1138 (not (re-search-backward (car sep) beg t)))
1139 (setq sep (cdr sep)))
1140 (point))) ;; if no separator found, returns end.
1143 (defun wl-highlight-message (start end hack-sig &optional body-only)
1144 "Highlight message headers between start and end.
1146 wl-highlight-message-headers the part before the colon
1147 wl-highlight-message-header-contents the part after the colon
1148 wl-highlight-message-important-header-contents contents of \"important\"
1150 wl-highlight-message-important-header-contents2 contents of \"important\"
1152 wl-highlight-message-unimportant-header-contents contents of unimportant
1154 wl-highlight-message-cited-text-N quoted text from other
1156 wl-highlight-message-citation-header header of quoted texts
1157 wl-highlight-message-signature signature
1160 wl-highlight-message-header-alist alist of header regexp with
1161 face for header contents
1162 wl-highlight-citation-prefix-regexp matches lines of quoted text
1163 wl-highlight-force-citation-header-regexp matches headers for quoted text
1164 wl-highlight-citation-header-regexp matches headers for quoted text
1166 If HACK-SIG is true,then we search backward from END for something that
1167 looks like the beginning of a signature block, and don't consider that a
1168 part of the message (this is because signatures are often incorrectly
1169 interpreted as cited text.)"
1171 (let ((s start)) (setq start end end s)))
1172 (let ((too-big (and wl-highlight-max-message-size
1174 wl-highlight-max-message-size)))
1182 ;; take off signature
1183 (if (and hack-sig (not too-big))
1184 (setq end (funcall wl-highlight-signature-search-function
1185 (- end wl-max-signature-size) end)))
1187 (not (eq end real-end)))
1188 (put-text-property end (point-max)
1189 'face 'wl-highlight-message-signature))
1190 (narrow-to-region start end)
1192 ;; narrow down to just the headers...
1194 ;; If this search fails then the narrowing performed above
1196 (if (re-search-forward (format
1198 (regexp-quote mail-header-separator))
1200 (narrow-to-region (point-min) (match-beginning 0)))
1201 ;; highlight only when header is not too-big.
1202 (when (or (null wl-highlight-max-header-size)
1203 (< (point) wl-highlight-max-header-size))
1205 (while (and (not body-only)
1207 (if (looking-at "^[^ \t\n:]+[ \t]*:[ \t]*")
1209 (put-text-property (match-beginning 0) (match-end 0)
1210 'face 'wl-highlight-message-headers)
1211 (setq p (match-end 0))
1212 (setq hend (save-excursion (std11-field-end end)))
1214 (let ((regexp-alist wl-highlight-message-header-alist))
1216 (when (save-match-data
1217 (looking-at (caar regexp-alist)))
1218 (put-text-property p hend 'face
1219 (cdar regexp-alist))
1221 (setq regexp-alist (cdr regexp-alist)))
1222 (throw 'match nil)))
1224 p hend 'face 'wl-highlight-message-header-contents))
1226 ;; ignore non-header field name lines
1227 (forward-line 1)))))
1228 (let (prefix prefix-face-alist pair end)
1231 ((looking-at (concat "^" (regexp-quote mail-header-separator) "$"))
1232 (put-text-property (match-beginning 0) (match-end 0)
1233 'face 'wl-highlight-header-separator-face)
1234 (goto-char (match-end 0)))
1235 ((null wl-highlight-force-citation-header-regexp)
1237 ((looking-at wl-highlight-force-citation-header-regexp)
1238 (setq current 'wl-highlight-message-citation-header)
1239 (setq end (match-end 0)))
1240 ((null wl-highlight-citation-prefix-regexp)
1242 ((looking-at wl-highlight-citation-prefix-regexp)
1243 (setq prefix (buffer-substring (point)
1245 (setq pair (assoc prefix prefix-face-alist))
1247 (setq prefix-face-alist
1248 (append prefix-face-alist
1254 (% (length prefix-face-alist)
1256 wl-highlight-citation-face-list))
1257 wl-highlight-citation-face-list)))))))
1258 (unless wl-highlight-highlight-citation-too
1259 (goto-char (match-end 0)))
1260 (setq current (cdr pair)))
1261 ((null wl-highlight-citation-header-regexp)
1263 ((looking-at wl-highlight-citation-header-regexp)
1264 (setq current 'wl-highlight-message-citation-header)
1265 (setq end (match-end 0)))
1266 (t (setq current nil)))
1269 (forward-line 1) ; this is to put the \n in the face too
1271 ;;; ((inhibit-read-only t))
1272 (put-text-property p (or end (point))
1277 (run-hooks 'wl-highlight-message-hook))))))
1279 ;; highlight-mouse-line for folder mode
1281 (defun wl-highlight-folder-mouse-line ()
1283 (let* ((end (save-excursion (end-of-line) (point)))
1285 (re-search-forward "[^ ]" end t)
1287 (inhibit-read-only t))
1288 (put-text-property beg end 'mouse-face 'highlight)))
1292 (product-provide (provide 'wl-highlight) (require 'wl-version))
1294 ;;; wl-highlight.el ends here