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 (defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
752 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
753 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
755 (defvar wl-highlight-citation-face-list
756 '(wl-highlight-message-cited-text-1
757 wl-highlight-message-cited-text-2
758 wl-highlight-message-cited-text-3
759 wl-highlight-message-cited-text-4
760 wl-highlight-message-cited-text-5
761 wl-highlight-message-cited-text-6
762 wl-highlight-message-cited-text-7
763 wl-highlight-message-cited-text-8
764 wl-highlight-message-cited-text-9
765 wl-highlight-message-cited-text-10))
767 (defmacro wl-delete-all-overlays ()
768 "Delete all momentary overlays."
769 '(let ((overlays (overlays-in (point-min) (point-max)))
771 (while (setq overlay (car overlays))
772 (if (overlay-get overlay 'wl-momentary-overlay)
773 (delete-overlay overlay))
774 (setq overlays (cdr overlays)))))
776 (defun wl-highlight-summary-displaying ()
778 (wl-delete-all-overlays)
785 (setq ov (make-overlay bol eol))
786 (overlay-put ov 'face 'wl-highlight-summary-displaying-face)
787 (overlay-put ov 'evaporate t)
788 (overlay-put ov 'wl-momentary-overlay t))))
790 (defun wl-highlight-folder-group-line (numbers)
796 (let ((text-face (cond ((looking-at wl-highlight-folder-opened-regexp)
797 'wl-highlight-folder-opened-face)
798 ((looking-at wl-highlight-folder-closed-regexp)
799 'wl-highlight-folder-closed-face))))
800 (if (and wl-highlight-folder-by-numbers
801 (re-search-forward "[0-9-]+/[0-9-]+/[0-9-]+" eol t))
802 (let* ((unsync (nth 0 numbers))
803 (unread (nth 1 numbers))
804 (face (cond ((and unsync (zerop unsync))
805 (if (and unread (> unread 0))
806 'wl-highlight-folder-unread-face
807 'wl-highlight-folder-zero-face))
809 (>= unsync wl-folder-many-unsync-threshold))
810 'wl-highlight-folder-many-face)
812 'wl-highlight-folder-few-face))))
813 (if (numberp wl-highlight-folder-by-numbers)
815 (put-text-property bol (match-beginning 0) 'face text-face)
816 (put-text-property (match-beginning 0) (match-end 0)
818 ;; Remove previous face.
819 (put-text-property bol (match-end 0) 'face nil)
820 (put-text-property bol (match-end 0) 'face face)))
821 (put-text-property bol eol 'face text-face)))))
823 (defun wl-highlight-summary-line-string (line mark temp-mark indent)
824 (let (fsymbol action)
825 (cond ((and (string= temp-mark wl-summary-score-over-mark)
826 (member mark (list wl-summary-unread-cached-mark
827 wl-summary-unread-uncached-mark
828 wl-summary-new-mark)))
829 (setq fsymbol 'wl-highlight-summary-high-unread-face))
830 ((and (string= temp-mark wl-summary-score-below-mark)
831 (member mark (list wl-summary-unread-cached-mark
832 wl-summary-unread-uncached-mark
833 wl-summary-new-mark)))
834 (setq fsymbol 'wl-highlight-summary-low-unread-face))
835 ((setq action (assoc temp-mark wl-summary-mark-action-list))
836 (setq fsymbol (nth 5 action)))
837 ((string= mark wl-summary-new-mark)
838 (setq fsymbol 'wl-highlight-summary-new-face))
839 ((member mark (list wl-summary-unread-cached-mark
840 wl-summary-unread-uncached-mark))
841 (setq fsymbol 'wl-highlight-summary-unread-face))
842 ((member mark (list wl-summary-answered-cached-mark
843 wl-summary-answered-uncached-mark))
844 (setq fsymbol 'wl-highlight-summary-answered-face))
845 ((or (string= mark wl-summary-important-mark))
846 (setq fsymbol 'wl-highlight-summary-important-face))
847 ((string= temp-mark wl-summary-score-below-mark)
848 (setq fsymbol 'wl-highlight-summary-low-read-face))
849 ((string= temp-mark wl-summary-score-over-mark)
850 (setq fsymbol 'wl-highlight-summary-high-read-face))
851 (t (if (zerop (length indent))
852 (setq fsymbol 'wl-highlight-summary-thread-top-face)
853 (setq fsymbol 'wl-highlight-summary-normal-face))))
854 (put-text-property 0 (length line) 'face fsymbol line))
855 (if wl-use-highlight-mouse-line
856 (put-text-property 0 (length line) 'mouse-face 'highlight line)))
858 (defun wl-highlight-summary-current-line ()
861 (let ((inhibit-read-only t)
862 (case-fold-search nil) temp-mark status-mark
863 (deactivate-mark nil)
864 fsymbol action bol eol matched thread-top looked-at dest ds)
869 (setq status-mark (wl-summary-persistent-mark))
870 (setq temp-mark (wl-summary-temp-mark))
871 (when (setq action (assoc temp-mark wl-summary-mark-action-list))
872 (setq fsymbol (nth 5 action))
873 (setq dest (nth 2 action)))
876 ((and (string= temp-mark wl-summary-score-over-mark)
877 (member status-mark (list wl-summary-unread-cached-mark
878 wl-summary-unread-uncached-mark
879 wl-summary-new-mark)))
880 (setq fsymbol 'wl-highlight-summary-high-unread-face))
881 ((and (string= temp-mark wl-summary-score-below-mark)
882 (member status-mark (list wl-summary-unread-cached-mark
883 wl-summary-unread-uncached-mark
884 wl-summary-new-mark)))
885 (setq fsymbol 'wl-highlight-summary-low-unread-face))
886 ((string= status-mark wl-summary-new-mark)
887 (setq fsymbol 'wl-highlight-summary-new-face))
888 ((member status-mark (list wl-summary-unread-cached-mark
889 wl-summary-unread-uncached-mark))
890 (setq fsymbol 'wl-highlight-summary-unread-face))
891 ((member status-mark (list wl-summary-answered-cached-mark
892 wl-summary-answered-uncached-mark))
893 (setq fsymbol 'wl-highlight-summary-answered-face))
894 ((string= status-mark wl-summary-important-mark)
895 (setq fsymbol 'wl-highlight-summary-important-face))
897 ((string= temp-mark wl-summary-score-below-mark)
898 (setq fsymbol 'wl-highlight-summary-low-read-face))
899 ((string= temp-mark wl-summary-score-over-mark)
900 (setq fsymbol 'wl-highlight-summary-high-read-face))
903 (wl-thread-entity-get-parent-entity
904 (wl-thread-get-entity (wl-summary-message-number))))
905 (setq fsymbol 'wl-highlight-summary-thread-top-face)
906 (setq fsymbol 'wl-highlight-summary-normal-face)))))
907 (put-text-property bol eol 'face fsymbol)
909 (put-text-property (next-single-property-change
910 (next-single-property-change
911 bol 'wl-summary-action-argument
913 'wl-summary-action-argument nil eol)
916 'wl-highlight-action-argument-face))
917 (if wl-use-highlight-mouse-line
918 (put-text-property bol
919 eol 'mouse-face 'highlight))
921 (wl-dnd-set-drag-starter bol eol)))))
923 (defun wl-highlight-folder (start end)
924 "Highlight folder between start and end.
926 wl-highlight-folder-unknown-face unread messages
927 wl-highlight-folder-zero-face folder needs no sync
928 wl-highlight-folder-few-face folder contains few unsync messages
929 wl-highlight-folder-many-face folder contains many unsync messages
930 wl-highlight-folder-opened-face opened group folder
931 wl-highlight-folder-closed-face closed group folder
934 wl-highlight-folder-opened-regexp matches opened group folder
935 wl-highlight-folder-closed-regexp matches closed group folder
939 (let ((s start)) (setq start end end s)))
940 (let* ((lines (count-lines start end))
946 (narrow-to-region start end)
950 (wl-highlight-folder-current-line)
951 (forward-line 1)))))))
953 (defun wl-highlight-folder-path (folder-path)
954 "Highlight current folder path...overlay"
956 (wl-delete-all-overlays)
957 (let ((fp folder-path) ov)
958 (goto-char (point-min))
962 (or (looking-at "^[ ]*\\[[\\+-]\\]\\(.+\\):.*\n")
963 (looking-at "^[ ]*\\([^ \\[].+\\):.*\n"))
965 (get-text-property (point) 'wl-folder-entity-id)
968 (setq ov (make-overlay
971 (setq wl-folder-buffer-cur-point (point))
972 (overlay-put ov 'face 'wl-highlight-folder-path-face)
973 (overlay-put ov 'evaporate t)
974 (overlay-put ov 'wl-momentary-overlay t))
977 (defun wl-highlight-action-argument-string (string)
978 (put-text-property 0 (length string) 'face
979 'wl-highlight-action-argument-face
982 (defun wl-highlight-summary-all ()
985 (wl-highlight-summary (point-min)(point-max)))
987 (defun wl-highlight-summary (start end &optional lazy)
988 "Highlight summary between start and end.
990 wl-highlight-summary-unread-face unread messages
991 wl-highlight-summary-important-face important messages
992 wl-highlight-summary-deleted-face messages mark as deleted
993 wl-highlight-summary-refiled-face messages mark as refiled
994 wl-highlight-summary-copied-face messages mark as copied
995 wl-highlight-summary-new-face new messages"
997 (let ((s start)) (setq start end end s)))
998 (let (lines too-big gc-message e p hend i percent)
1000 (unless wl-summary-lazy-highlight
1001 (setq lines (count-lines start end)
1002 too-big (and wl-highlight-max-summary-lines
1003 (> lines wl-highlight-max-summary-lines))))
1006 (while (and (not (eobp))
1008 (when (or (not lazy)
1009 (null (get-text-property (point) 'face)))
1010 (wl-highlight-summary-current-line))
1012 (unless wl-summary-lazy-highlight
1013 (message "Highlighting...done")))))
1015 (defun wl-highlight-summary-window (&optional win beg)
1016 "Highlight summary window.
1017 This function is defined for `window-scroll-functions'"
1018 (when wl-summary-highlight
1019 (with-current-buffer (window-buffer win)
1020 (when (eq major-mode 'wl-summary-mode)
1021 (let ((start (window-start win))
1022 (end (condition-case nil
1023 (window-end win t) ;; old emacsen doesn't support 2nd arg.
1024 (error (window-end win)))))
1025 (wl-highlight-summary start
1028 (set-buffer-modified-p nil)))))
1030 (defun wl-highlight-headers (&optional for-draft)
1031 (let ((beg (point-min))
1032 (end (or (save-excursion (re-search-forward "^$" nil t)
1035 (wl-highlight-message beg end nil)
1037 (when wl-highlight-x-face-function
1038 (funcall wl-highlight-x-face-function)))
1039 (run-hooks 'wl-highlight-headers-hook)))
1041 (defun wl-highlight-body-all ()
1042 (wl-highlight-message (point-min) (point-max) t t))
1044 (defun wl-highlight-body ()
1045 (let ((beg (or (save-excursion (goto-char (point-min))
1046 (re-search-forward "^$" nil t))
1049 (wl-highlight-message beg end t)))
1051 (defun wl-highlight-body-region (beg end)
1052 (wl-highlight-message beg end t t))
1054 (defun wl-highlight-signature-search-simple (beg end)
1055 "Search signature area in the body message between BEG and END.
1056 Returns start point of signature."
1059 (if (re-search-backward "\n--+ *\n" beg t)
1060 (if (eq (char-after (point)) ?\n)
1065 (defun wl-highlight-signature-search (beg end)
1066 "Search signature area in the body message between BEG and END.
1067 Returns start point of signature."
1071 ;; look for legal signature separator (check at first for fasten)
1072 (re-search-backward "\n-- \n" beg t)
1074 ;; look for dual separator
1077 (re-search-backward "^[^A-Za-z0-9> \t\n]+ *$" beg t)
1078 (> (- (match-end 0) (match-beginning 0)) 10);; "10" is a magic number.
1081 (regexp-quote (buffer-substring (match-beginning 0) (match-end 0)))
1084 ;; look for user specified signature-separator
1085 (if (stringp wl-highlight-signature-separator)
1086 (re-search-backward wl-highlight-signature-separator nil t);; case one string
1087 (let ((sep wl-highlight-signature-separator)) ;; case list
1089 (not (re-search-backward (car sep) beg t)))
1090 (setq sep (cdr sep)))
1091 (point))) ;; if no separator found, returns end.
1094 (defun wl-highlight-message (start end hack-sig &optional body-only)
1095 "Highlight message headers between start and end.
1097 wl-highlight-message-headers the part before the colon
1098 wl-highlight-message-header-contents the part after the colon
1099 wl-highlight-message-important-header-contents contents of \"special\"
1101 wl-highlight-message-important-header-contents2 contents of \"special\"
1103 wl-highlight-message-unimportant-header-contents contents of unimportant
1105 wl-highlight-message-cited-text quoted text from other
1107 wl-highlight-message-citation-header header of quoted texts
1108 wl-highlight-message-signature signature
1111 wl-highlight-important-header-regexp what makes a \"special\" header
1112 wl-highlight-important-header2-regexp what makes a \"special\" header
1113 wl-highlight-unimportant-header-regexp what makes a \"special\" header
1114 wl-highlight-citation-prefix-regexp matches lines of quoted text
1115 wl-highlight-citation-header-regexp matches headers for quoted text
1117 If HACK-SIG is true,then we search backward from END for something that
1118 looks like the beginning of a signature block, and don't consider that a
1119 part of the message (this is because signatures are often incorrectly
1120 interpreted as cited text.)"
1122 (let ((s start)) (setq start end end s)))
1123 (let ((too-big (and wl-highlight-max-message-size
1125 wl-highlight-max-message-size)))
1133 ;; take off signature
1134 (if (and hack-sig (not too-big))
1135 (setq end (funcall wl-highlight-signature-search-function
1136 (- end wl-max-signature-size) end)))
1138 (not (eq end real-end)))
1139 (put-text-property end (point-max)
1140 'face 'wl-highlight-message-signature))
1141 (narrow-to-region start end)
1143 ;; narrow down to just the headers...
1145 ;; If this search fails then the narrowing performed above
1147 (if (re-search-forward (format
1149 (regexp-quote mail-header-separator))
1151 (narrow-to-region (point-min) (match-beginning 0)))
1152 ;; highlight only when header is not too-big.
1153 (when (or (null wl-highlight-max-header-size)
1154 (< (point) wl-highlight-max-header-size))
1156 (while (and (not body-only)
1158 (if (looking-at "^[^ \t\n:]+[ \t]*:")
1160 (put-text-property (match-beginning 0) (match-end 0)
1161 'face 'wl-highlight-message-headers)
1162 (setq p (match-end 0))
1163 (setq hend (save-excursion (std11-field-end end)))
1165 (let ((regexp-alist wl-highlight-message-header-alist))
1167 (when (save-match-data
1168 (looking-at (caar regexp-alist)))
1169 (put-text-property p hend 'face
1170 (cdar regexp-alist))
1172 (setq regexp-alist (cdr regexp-alist)))
1173 (throw 'match nil)))
1175 p hend 'face 'wl-highlight-message-header-contents))
1177 ;; ignore non-header field name lines
1178 (forward-line 1)))))
1179 (let (prefix prefix-face-alist pair end)
1182 ((looking-at mail-header-separator)
1183 (put-text-property (match-beginning 0) (match-end 0)
1184 'face 'wl-highlight-header-separator-face)
1185 (goto-char (match-end 0)))
1186 ((null wl-highlight-force-citation-header-regexp)
1188 ((looking-at wl-highlight-force-citation-header-regexp)
1189 (setq current 'wl-highlight-message-citation-header)
1190 (setq end (match-end 0)))
1191 ((null wl-highlight-citation-prefix-regexp)
1193 ((looking-at wl-highlight-citation-prefix-regexp)
1194 (setq prefix (buffer-substring (point)
1196 (setq pair (assoc prefix prefix-face-alist))
1198 (setq prefix-face-alist
1199 (append prefix-face-alist
1205 (% (length prefix-face-alist)
1207 wl-highlight-citation-face-list))
1208 wl-highlight-citation-face-list)))))))
1209 (unless wl-highlight-highlight-citation-too
1210 (goto-char (match-end 0)))
1211 (setq current (cdr pair)))
1212 ((null wl-highlight-citation-header-regexp)
1214 ((looking-at wl-highlight-citation-header-regexp)
1215 (setq current 'wl-highlight-message-citation-header)
1216 (setq end (match-end 0)))
1217 (t (setq current nil)))
1220 (forward-line 1) ; this is to put the \n in the face too
1222 ;;; ((inhibit-read-only t))
1223 (put-text-property p (or end (point))
1228 (run-hooks 'wl-highlight-message-hook))))))
1230 ;; highlight-mouse-line for folder mode
1232 (defun wl-highlight-folder-mouse-line ()
1234 (let* ((end (save-excursion (end-of-line) (point)))
1236 (re-search-forward "[^ ]" end t)
1238 (inhibit-read-only t))
1239 (put-text-property beg end 'mouse-face 'highlight)))
1242 (product-provide (provide 'wl-highlight) (require 'wl-version))
1244 ;;; wl-highlight.el ends here