1 ;;; wl-highlight.el -- Hilight modules for Wanderlust.
3 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
8 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
32 (if (and (featurep 'xemacs)
36 (provide 'wl-highlight)
44 (defun-maybe extent-begin-glyph (a))
45 (defun-maybe delete-extent (a))
46 (defun-maybe make-extent (a b))
47 (defun-maybe set-extent-begin-glyph (a b))
48 (defun-maybe set-extent-end-glyph (a b))
49 (defun-maybe extent-at (a b c d e))
50 (defun-maybe wl-dnd-set-drop-target (a b))
51 (defun-maybe wl-dnd-set-drag-starter (a b)))
53 (put 'wl-defface 'lisp-indent-function 'defun)
55 (defgroup wl-faces nil
57 :prefix "wl-highlight-"
61 (defgroup wl-summary-faces nil
62 "Wanderlust, Faces of summary buffer."
63 :prefix "wl-highlight-"
67 (defgroup wl-folder-faces nil
68 "Wanderlust, Faces of folder buffer."
69 :prefix "wl-highlight-"
73 (defgroup wl-message-faces nil
74 "Wanderlust, Faces of message buffer."
75 :prefix "wl-highlight-"
78 ;; for message header and signature
80 (wl-defface wl-highlight-message-headers
87 (:foreground "gray" :bold t))
90 (:foreground "gray50" :bold t)))
91 "Face used for displaying header names."
92 :group 'wl-message-faces
95 (wl-defface wl-highlight-message-header-contents
99 (:foreground "green"))
102 (:foreground "LightSkyBlue" :bold t))
105 (:foreground "purple" :bold t)))
106 "Face used for displaying header content."
107 :group 'wl-message-faces
110 (wl-defface wl-highlight-message-important-header-contents
114 (:foreground "yellow"))
117 (:foreground "yellow" :bold t))
120 (:foreground "brown" :bold t)))
121 "Face used for displaying contents of special headers."
122 :group 'wl-message-faces
125 (wl-defface wl-highlight-message-important-header-contents2
132 (:foreground "orange" :bold t))
135 (:foreground "DarkSlateBlue" :bold t)))
136 "Face used for displaying contents of special headers."
137 :group 'wl-message-faces
140 (wl-defface wl-highlight-message-citation-header
144 (:foreground "cyan"))
147 (:foreground "SkyBlue"))
150 (:foreground "DarkGreen")))
151 "Face used for displaying header of quoted texts."
152 :group 'wl-message-faces
155 (wl-defface wl-highlight-message-unimportant-header-contents
159 (:foreground "green"))
162 (:foreground "GreenYellow" :bold t))
165 (:foreground "DarkGreen" :bold t)))
166 "Face used for displaying contents of unimportant headers."
167 :group 'wl-message-faces
170 (wl-defface wl-highlight-message-signature
173 (:foreground "khaki"))
176 (:foreground "DarkSlateBlue")))
177 "Face used for displaying signature."
178 :group 'wl-message-faces
183 (wl-defface wl-highlight-header-separator-face
187 (:foreground "black" :background "yellow"))
189 (:foreground "Black" :background "DarkKhaki")))
190 "Face used for displaying header separator."
194 ;; important messages
196 (wl-defface wl-highlight-summary-important-face
200 (:foreground "magenta"))
203 (:foreground "orange"))
206 (:foreground "purple")))
207 "Face used for displaying important messages."
208 :group 'wl-summary-faces
211 (wl-defface wl-highlight-summary-new-face
218 (:foreground "tomato"))
221 (:foreground "tomato")))
222 "Face used for displaying new messages."
223 :group 'wl-summary-faces
226 (wl-defface wl-highlight-summary-displaying-face
228 (:underline t :bold t)))
229 "Face used for displaying message."
230 :group 'wl-summary-faces
233 (wl-defface wl-highlight-thread-indent-face
235 (:foreground "gray40")))
236 "Face used for displaying indented thread."
237 :group 'wl-summary-faces
240 ;; unimportant messages
242 (wl-defface wl-highlight-summary-unread-face
246 (:foreground "cyan"))
249 (:foreground "LightSkyBlue"))
252 (:foreground "RoyalBlue")))
253 "Face used for displaying unread messages."
254 :group 'wl-summary-faces
257 (wl-defface wl-highlight-summary-deleted-face
261 (:foreground "blue"))
264 (:foreground "gray"))
267 (:foreground "DarkKhaki")))
268 "Face used for displaying messages mark as deleted."
269 :group 'wl-summary-faces
272 (wl-defface wl-highlight-summary-refiled-face
276 (:foreground "blue"))
279 (:foreground "blue"))
282 (:foreground "firebrick")))
283 "Face used for displaying messages mark as refiled."
284 :group 'wl-summary-faces
287 (wl-defface wl-highlight-summary-copied-face
291 (:foreground "blue"))
294 (:foreground "cyan"))
297 (:foreground "blue")))
298 "Face used for displaying messages mark as copied."
299 :group 'wl-summary-faces
303 (wl-defface wl-highlight-summary-temp-face
307 (:foreground "gold"))
309 (:foreground "HotPink1")))
310 "Face used for displaying messages mark as temp."
311 :group 'wl-summary-faces
314 (wl-defface wl-highlight-summary-target-face
318 (:foreground "gold"))
320 (:foreground "HotPink1")))
321 "Face used for displaying messages mark as target."
322 :group 'wl-summary-faces
325 (wl-defface wl-highlight-summary-low-read-face
329 (:foreground "yellow" :italic t))
332 (:foreground "PaleGreen" :italic t))
335 (:foreground "Green3" :italic t)))
336 "Face used for displaying low interest read messages."
337 :group 'wl-summary-faces
340 (wl-defface wl-highlight-summary-high-read-face
346 (:foreground "PaleGreen" :bold t))
349 (:foreground "SeaGreen" :bold t)))
350 "Face used for displaying high interest read messages."
351 :group 'wl-summary-faces
354 (wl-defface wl-highlight-summary-low-unread-face
358 (:foreground "cyan" :italic t))
361 (:foreground "LightSkyBlue" :italic t))
364 (:foreground "RoyalBlue" :italic t)))
365 "Face used for displaying low interest unread messages."
366 :group 'wl-summary-faces
369 (wl-defface wl-highlight-summary-high-unread-face
372 (:foreground "red" :bold t))
375 (:foreground "tomato" :bold t))
378 (:foreground "tomato" :bold t)))
379 "Face used for displaying high interest unread messages."
380 :group 'wl-summary-faces
385 (wl-defface wl-highlight-summary-thread-top-face
389 (:foreground "green"))
392 (:foreground "GreenYellow"))
395 (:foreground "green4")))
396 "Face used for displaying top thread message."
397 :group 'wl-summary-faces
400 (wl-defface wl-highlight-summary-normal-face
404 (:foreground "yellow"))
407 (:foreground "PaleGreen"))
410 (:foreground "SeaGreen")))
411 "Face used for displaying normal message."
412 :group 'wl-summary-faces
417 (wl-defface wl-highlight-folder-unknown-face
421 (:foreground "cyan"))
424 (:foreground "pink"))
427 (:foreground "RoyalBlue")))
428 "Face used for displaying unread folder."
429 :group 'wl-folder-faces
432 (wl-defface wl-highlight-folder-killed-face
436 (:foreground "gray"))
438 (:foreground "gray50")))
439 "Face used for displaying killed folder."
440 :group 'wl-folder-faces
443 (wl-defface wl-highlight-folder-zero-face
447 (:foreground "green"))
450 (:foreground "SkyBlue"))
453 (:foreground "BlueViolet")))
454 "Face used for displaying folder needs no sync."
455 :group 'wl-folder-faces
458 (wl-defface wl-highlight-folder-few-face
462 (:foreground "yellow"))
465 (:foreground "orange"))
468 (:foreground "OrangeRed3")))
469 "Face used for displaying folder contains few unsync messages."
470 :group 'wl-folder-faces
473 (wl-defface wl-highlight-folder-many-face
480 (:foreground "HotPink1"))
483 (:foreground "tomato")))
484 "Face used for displaying folder contains many unsync messages."
485 :group 'wl-folder-faces
488 (wl-defface wl-highlight-folder-unread-face
492 (:foreground "magenta"))
495 (:foreground "gold"))
498 (:foreground "MediumVioletRed")))
499 "Face used for displaying unread folder."
500 :group 'wl-folder-faces
503 (wl-defface wl-highlight-folder-opened-face
507 (:foreground "blue"))
510 (:foreground "PaleGreen"))
513 (:foreground "ForestGreen")))
514 "Face used for displaying opened group folder."
515 :group 'wl-folder-faces
518 (wl-defface wl-highlight-folder-closed-face
522 (:foreground "cyan"))
525 (:foreground "GreenYellow"))
528 (:foreground "DarkOliveGreen4")))
529 "Face used for displaying closed group folder."
530 :group 'wl-folder-faces
533 (wl-defface wl-highlight-folder-path-face
535 (:bold t :underline t)))
536 "Face used for displaying path."
537 :group 'wl-folder-faces
540 (wl-defface wl-highlight-demo-face
544 (:foreground "green"))
547 (:foreground "GreenYellow"))
550 (:foreground "blue2")))
551 "Face used for displaying demo."
554 (wl-defface wl-highlight-logo-face
558 (:foreground "cyan"))
561 (:foreground "SkyBlue"))
564 (:foreground "SteelBlue")))
565 "Face used for displaying demo."
568 (wl-defface wl-highlight-refile-destination-face
571 (:foreground "pink"))
574 (:foreground "red")))
575 "Face used for displaying refile destination."
576 :group 'wl-summary-faces
581 (wl-defface wl-highlight-message-cited-text-1
585 (:foreground "magenta"))
588 (:foreground "HotPink1"))
591 (:foreground "ForestGreen")))
592 "Face used for displaying quoted text from other messages."
593 :group 'wl-message-faces
596 (wl-defface wl-highlight-message-cited-text-2
600 (:foreground "blue"))
602 (:foreground "violet")))
603 "Face used for displaying quoted text from other messages."
604 :group 'wl-message-faces
607 (wl-defface wl-highlight-message-cited-text-3
611 (:foreground "cyan"))
613 (:foreground "orchid3")))
614 "Face used for displaying quoted text from other messages."
615 :group 'wl-message-faces
618 (wl-defface wl-highlight-message-cited-text-4
622 (:foreground "green"))
624 (:foreground "purple1")))
625 "Face used for displaying quoted text from other messages."
626 :group 'wl-message-faces
629 (wl-defface wl-highlight-message-cited-text-5
633 (:foreground "yellow"))
635 (:foreground "MediumPurple1")))
636 "Face used for displaying quoted text from other messages."
637 :group 'wl-message-faces
640 (wl-defface wl-highlight-message-cited-text-6
646 (:foreground "PaleVioletRed")))
647 "Face used for displaying quoted text from other messages."
648 :group 'wl-message-faces
651 (wl-defface wl-highlight-message-cited-text-7
655 (:foreground "magenta"))
657 (:foreground "LightPink")))
658 "Face used for displaying quoted text from other messages."
659 :group 'wl-message-faces
662 (wl-defface wl-highlight-message-cited-text-8
666 (:foreground "blue"))
668 (:foreground "salmon")))
669 "Face used for displaying quoted text from other messages."
670 :group 'wl-message-faces
673 (wl-defface wl-highlight-message-cited-text-9
677 (:foreground "cyan"))
679 (:foreground "SandyBrown")))
680 "Face used for displaying quoted text from other messages."
681 :group 'wl-message-faces
684 (wl-defface wl-highlight-message-cited-text-10
688 (:foreground "green"))
690 (:foreground "wheat")))
691 "Face used for displaying quoted text from other messages."
692 :group 'wl-message-faces
695 (defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
696 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
697 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
699 (defvar wl-highlight-summary-unread-regexp " *[0-9]+[^0-9]\\(!\\|U\\)")
700 (defvar wl-highlight-summary-important-regexp " *[0-9]+[^0-9]\\$")
701 (defvar wl-highlight-summary-new-regexp " *[0-9]+[^0-9]N")
702 (defvar wl-highlight-summary-deleted-regexp " *[0-9]+D")
703 (defvar wl-highlight-summary-refiled-regexp " *[0-9]+o")
704 (defvar wl-highlight-summary-copied-regexp " *[0-9]+O")
705 (defvar wl-highlight-summary-target-regexp " *[0-9]+\\*")
706 ;(defvar wl-highlight-summary-thread-top-regexp " *[0-9]+[^0-9][^0-9]../..\(.*\)..:.. \\[")
708 (defvar wl-highlight-citation-face-list
709 '(wl-highlight-message-cited-text-1
710 wl-highlight-message-cited-text-2
711 wl-highlight-message-cited-text-3
712 wl-highlight-message-cited-text-4
713 wl-highlight-message-cited-text-5
714 wl-highlight-message-cited-text-6
715 wl-highlight-message-cited-text-7
716 wl-highlight-message-cited-text-8
717 wl-highlight-message-cited-text-9
718 wl-highlight-message-cited-text-10))
720 (defmacro defun-hilit (name &rest everything-else)
721 "Define a function for highlight. Nemacs implementation is set as empty."
723 (` (defun (, name) nil nil))
724 (` (defun (, name) (,@ everything-else)))))
726 (defmacro defun-hilit2 (name &rest everything-else)
727 "Define a function for highlight w/o nemacs."
730 (` (defun (, name) (,@ everything-else)))))
732 (defun-hilit wl-highlight-summary-displaying ()
734 (wl-delete-all-overlays)
739 (save-excursion (end-of-line) (setq eol (point)))
740 (setq ov (make-overlay bol eol))
741 (overlay-put ov 'face 'wl-highlight-summary-displaying-face))))
743 (defun-hilit2 wl-highlight-folder-group-line (numbers)
744 (if wl-highlight-group-folder-by-numbers
745 (let (fsymbol bol eol)
748 (save-excursion (end-of-line) (setq eol (point)))
750 (let ((unsync (nth 0 numbers))
751 (unread (nth 1 numbers)))
752 (cond ((and unsync (eq unsync 0))
753 (if (and unread (> unread 0))
754 'wl-highlight-folder-unread-face
755 'wl-highlight-folder-zero-face))
757 (>= unsync wl-folder-many-unsync-threshold))
758 'wl-highlight-folder-many-face)
760 'wl-highlight-folder-few-face))))
761 (put-text-property bol eol 'face fsymbol))
762 (let ((highlights (list "opened" "closed"))
763 fregexp fsymbol bol eol matched type extent num type)
766 (save-excursion (end-of-line) (setq eol (point)))
769 (setq fregexp (symbol-value
770 (intern (format "wl-highlight-folder-%s-regexp"
772 (setq fsymbol (intern (format "wl-highlight-folder-%s-face"
774 (when (looking-at fregexp)
775 (put-text-property bol eol 'face fsymbol)
777 (throw 'highlighted nil))
778 (setq highlights (cdr highlights)))))))
780 (defun-hilit2 wl-highlight-summary-line-string (line mark temp-mark indent)
782 (cond ((and (string= temp-mark "+")
783 (member mark (list wl-summary-unread-cached-mark
784 wl-summary-unread-uncached-mark
785 wl-summary-new-mark)))
786 (setq fsymbol 'wl-highlight-summary-high-unread-face))
787 ((and (string= temp-mark "-")
788 (member mark (list wl-summary-unread-cached-mark
789 wl-summary-unread-uncached-mark
790 wl-summary-new-mark)))
791 (setq fsymbol 'wl-highlight-summary-low-unread-face))
792 ((string= temp-mark "o")
793 (setq fsymbol 'wl-highlight-summary-refiled-face))
794 ((string= temp-mark "O")
795 (setq fsymbol 'wl-highlight-summary-copied-face))
796 ((string= temp-mark "D")
797 (setq fsymbol 'wl-highlight-summary-deleted-face))
798 ((string= temp-mark "*")
799 (setq fsymbol 'wl-highlight-summary-temp-face))
800 ((string= mark wl-summary-new-mark)
801 (setq fsymbol 'wl-highlight-summary-new-face))
802 ((member mark (list wl-summary-unread-cached-mark
803 wl-summary-unread-uncached-mark))
804 (setq fsymbol 'wl-highlight-summary-unread-face))
805 ((or (string= mark wl-summary-important-mark))
806 (setq fsymbol 'wl-highlight-summary-important-face))
807 ((string= temp-mark "-")
808 (setq fsymbol 'wl-highlight-summary-low-read-face))
809 ((string= temp-mark "+")
810 (setq fsymbol 'wl-highlight-summary-high-read-face))
811 (t (if (= 0 (length indent))
812 (setq fsymbol 'wl-highlight-summary-thread-top-face)
813 (setq fsymbol 'wl-highlight-summary-normal-face))))
814 (put-text-property 0 (length line) 'face fsymbol line))
815 (if wl-use-highlight-mouse-line
816 (put-text-property 0 (length line) 'mouse-face 'highlight line)))
818 (defun-hilit2 wl-highlight-summary-current-line (&optional smark regexp temp-too)
821 (let ((inhibit-read-only t)
822 (case-fold-search nil) temp-mark status-mark
825 wl-summary-buffer-number-regexp
826 "\\(.\\)\\(.\\)../..\(.*\)..:.. \\("
827 wl-highlight-thread-indent-string-regexp
829 fregexp fsymbol bol eol matched thread-top looked-at)
832 (save-excursion (end-of-line) (setq eol (point)))
834 (setq status-mark smark)
835 (setq looked-at (looking-at sregexp))
836 (setq status-mark (buffer-substring (match-beginning 2)
840 (setq looked-at (looking-at sregexp)))
842 (setq temp-mark (buffer-substring (match-beginning 1)
845 ((string= temp-mark "*")
846 (setq fsymbol 'wl-highlight-summary-temp-face))
847 ((string= temp-mark "D")
848 (setq fsymbol 'wl-highlight-summary-deleted-face))
849 ((string= temp-mark "O")
850 (setq fsymbol 'wl-highlight-summary-copied-face))
851 ((string= temp-mark "o")
852 (setq fsymbol 'wl-highlight-summary-refiled-face)))))
855 ((and (string= temp-mark "+")
856 (member status-mark (list wl-summary-unread-cached-mark
857 wl-summary-unread-uncached-mark
858 wl-summary-new-mark)))
859 (setq fsymbol 'wl-highlight-summary-high-unread-face))
860 ((and (string= temp-mark "-")
861 (member status-mark (list wl-summary-unread-cached-mark
862 wl-summary-unread-uncached-mark
863 wl-summary-new-mark)))
864 (setq fsymbol 'wl-highlight-summary-low-unread-face))
865 ((string= status-mark wl-summary-new-mark)
866 (setq fsymbol 'wl-highlight-summary-new-face))
867 ((member status-mark (list wl-summary-unread-cached-mark
868 wl-summary-unread-uncached-mark))
869 (setq fsymbol 'wl-highlight-summary-unread-face))
870 ((string= status-mark wl-summary-important-mark)
871 (setq fsymbol 'wl-highlight-summary-important-face))
873 ((string= temp-mark "-")
874 (setq fsymbol 'wl-highlight-summary-low-read-face))
875 ((string= temp-mark "+")
876 (setq fsymbol 'wl-highlight-summary-high-read-face))
878 (t (if (and looked-at
879 (string= (buffer-substring
882 (setq fsymbol 'wl-highlight-summary-thread-top-face)
883 (setq fsymbol 'wl-highlight-summary-normal-face)))))
884 (put-text-property bol eol 'face fsymbol)
885 (if wl-use-highlight-mouse-line
886 (put-text-property bol;(1- (match-end 0))
887 eol 'mouse-face 'highlight))
888 ; (put-text-property (match-beginning 3) (match-end 3)
889 ; 'face 'wl-highlight-thread-indent-face)
892 (wl-dnd-set-drag-starter bol eol)))))
894 (defun-hilit2 wl-highlight-folder (start end)
895 "Highlight folder between start and end.
897 wl-highlight-folder-unknown-face unread messages
898 wl-highlight-folder-zero-face folder needs no sync
899 wl-highlight-folder-few-face folder contains few unsync messages
900 wl-highlight-folder-many-face folder contains many unsync messages
901 wl-highlight-folder-opened-face opened group folder
902 wl-highlight-folder-closed-face closed group folder
905 wl-highlight-folder-opened-regexp matches opened group folder
906 wl-highlight-folder-closed-regexp matches closed group folder
910 (let ((s start)) (setq start end end s)))
911 (let* ((lines (count-lines start end))
917 (narrow-to-region start end)
921 (wl-highlight-folder-current-line)
922 (forward-line 1)))))))
924 (if (not wl-on-nemacs)
925 (defsubst wl-delete-all-overlays ()
928 (overlays-in (point-min) (point-max)))))
930 (defun-hilit2 wl-highlight-folder-path (folder-path)
931 "Highlight current folder path...overlay"
933 (wl-delete-all-overlays)
934 (let ((fp folder-path) ov)
935 (goto-char (point-min))
939 (or (looking-at "^[ ]*\\[[\\+-]\\]\\(.+\\):.*\n")
940 (looking-at "^[ ]*\\([^ \\[].+\\):.*\n"))
942 (get-text-property (point) 'wl-folder-entity-id)
945 (setq ov (make-overlay
948 (setq wl-folder-buffer-cur-point (point))
949 (overlay-put ov 'face 'wl-highlight-folder-path-face))
952 (defun-hilit2 wl-highlight-refile-destination-string (string)
953 (put-text-property 0 (length string) 'face
954 'wl-highlight-refile-destination-face
957 (defun-hilit wl-highlight-summary-all ()
960 (wl-highlight-summary (point-min)(point-max)))
962 (defun-hilit2 wl-highlight-summary (start end)
963 "Highlight summary between start and end.
965 wl-highlight-summary-unread-face unread messages
966 wl-highlight-summary-important-face important messages
967 wl-highlight-summary-deleted-face messages mark as deleted
968 wl-highlight-summary-refiled-face messages mark as refiled
969 wl-highlight-summary-copied-face messages mark as copied
970 wl-highlight-summary-new-face new messages
973 wl-highlight-summary-unread-regexp matches unread messages
974 wl-highlight-summary-important-regexp matches important messages
975 wl-highlight-summary-deleted-regexp matches messages mark as deleted
976 wl-highlight-summary-refiled-regexp matches messages mark as refiled
977 wl-highlight-summary-copied-regexp matches messages mark as copied
978 wl-highlight-summary-new-regexp matches new messages
980 If HACK-SIG is true,then we search backward from END for something that
981 looks like the beginning of a signature block, and don't consider that a
982 part of the message (this is because signatures are often incorrectly
983 interpreted as cited text.)"
985 (let ((s start)) (setq start end end s)))
986 (let* ((lines (count-lines start end))
987 (too-big (and wl-highlight-max-summary-lines
988 (> lines wl-highlight-max-summary-lines)))
995 (narrow-to-region start end)
1001 (wl-highlight-summary-current-line nil nil wl-summary-scored)
1003 (setq percent (/ (* i 100) lines))
1004 (if (eq (% percent 5) 0)
1005 (elmo-display-progress
1006 'wl-highlight-summary "Highlighting..."
1009 (message "Highlighting...done.")))))))
1011 (defun wl-highlight-headers ()
1012 (let ((beg (point-min))
1013 (end (or (save-excursion (re-search-forward "^$" nil t))
1015 (wl-highlight-message beg end nil)
1016 (and wl-highlight-x-face-func
1017 (funcall wl-highlight-x-face-func beg end))
1018 (run-hooks 'wl-highlight-headers-hook)))
1020 (defun wl-highlight-body-all ()
1021 (wl-highlight-message (point-min) (point-max) t t))
1023 (defun-hilit wl-highlight-body ()
1024 (let ((beg (or (save-excursion (goto-char (point-min))
1025 (re-search-forward "^$" nil t))
1028 (wl-highlight-message beg end t)))
1030 (defun-hilit2 wl-highlight-body-region (beg end)
1031 (wl-highlight-message beg end t t))
1033 (defun wl-highlight-signature-search-simple (beg end)
1034 "Search signature area in the body message between beg and end.
1035 Returns start point of signature."
1038 (if (re-search-backward "\n--+ *\n" beg t)
1039 (if (eq (char-after (point)) ?\n)
1044 (defun wl-highlight-signature-search (beg end)
1045 "Search signature area in the body message between beg and end.
1046 Returns start point of signature."
1050 ;; look for legal signature separator (check at first for fasten)
1051 (re-search-backward "\n-- \n" beg t)
1053 ;; look for dual separator
1056 (re-search-backward "^[^A-Za-z0-9> \t\n]+ *$" beg t)
1057 (> (- (match-end 0) (match-beginning 0)) 10);; "10" is a magic number.
1060 (regexp-quote (buffer-substring (match-beginning 0) (match-end 0)))
1063 ;; look for user specified signature-separator
1064 (if (stringp wl-highlight-signature-separator)
1065 (re-search-backward wl-highlight-signature-separator nil t);; case one string
1066 (let ((sep wl-highlight-signature-separator)) ;; case list
1068 (not (re-search-backward (car sep) beg t)))
1069 (setq sep (cdr sep)))
1070 (point))) ;; if no separator found, returns end.
1073 (defun-hilit2 wl-highlight-message (start end hack-sig &optional body-only)
1074 "Highlight message headers between start and end.
1076 wl-highlight-message-headers the part before the colon
1077 wl-highlight-message-header-contents the part after the colon
1078 wl-highlight-message-important-header-contents contents of \"special\"
1080 wl-highlight-message-important-header-contents2 contents of \"special\"
1082 wl-highlight-message-unimportant-header-contents contents of unimportant
1084 wl-highlight-message-cited-text quoted text from other
1086 wl-highlight-message-citation-header header of quoted texts
1087 wl-highlight-message-signature signature
1090 wl-highlight-important-header-regexp what makes a \"special\" header
1091 wl-highlight-important-header2-regexp what makes a \"special\" header
1092 wl-highlight-unimportant-header-regexp what makes a \"special\" header
1093 wl-highlight-citation-prefix-regexp matches lines of quoted text
1094 wl-highlight-citation-header-regexp matches headers for quoted text
1096 If HACK-SIG is true,then we search backward from END for something that
1097 looks like the beginning of a signature block, and don't consider that a
1098 part of the message (this is because signatures are often incorrectly
1099 interpreted as cited text.)"
1101 (let ((s start)) (setq start end end s)))
1102 (let* ((too-big (and wl-highlight-max-message-size
1104 wl-highlight-max-message-size)))
1111 ;; take off signature
1112 (if (and hack-sig (not too-big))
1113 (setq end (funcall wl-highlight-signature-search-func
1114 (- end wl-max-signature-size) end)))
1116 (put-text-property end (point-max)
1117 'face 'wl-highlight-message-signature))
1118 (narrow-to-region start end)
1121 ;; narrow down to just the headers...
1123 ;; If this search fails then the narrowing performed above
1125 (if (re-search-forward (format
1127 (regexp-quote mail-header-separator)) nil t)
1128 (narrow-to-region (point-min) (point)))
1130 (while (and (not body-only)
1133 ((looking-at "^\\([^ \t\n:]+[ \t]*:\\) *\\(.*\\(\n[ \t].*\\)*\n\\)")
1134 (setq hend (match-end 0))
1135 (put-text-property (match-beginning 1) (match-end 1)
1136 'face 'wl-highlight-message-headers)
1137 (setq p (match-end 1))
1140 (let ((regexp-alist wl-highlight-message-header-alist))
1142 (when (save-match-data
1143 (looking-at (caar regexp-alist)))
1145 (match-beginning 2) (match-end 2)
1147 (cdar regexp-alist))
1149 (setq regexp-alist (cdr regexp-alist)))
1150 (throw 'match nil))))
1153 (match-beginning 2) (match-end 2)
1154 'face 'wl-highlight-message-header-contents)))
1156 ((looking-at mail-header-separator)
1157 (put-text-property (match-beginning 0) (match-end 0)
1158 'face 'wl-highlight-header-separator-face)
1159 (goto-char (match-end 0)))
1160 ;; ignore non-header field name lines
1161 (t (forward-line 1)))))
1162 ;; now do the body, unless it's too big....
1165 (let (prefix prefix-face-alist pair end)
1168 ((null wl-highlight-force-citation-header-regexp)
1170 ((looking-at wl-highlight-force-citation-header-regexp)
1171 (setq current 'wl-highlight-message-citation-header)
1172 (setq end (match-end 0)))
1173 ((null wl-highlight-citation-prefix-regexp)
1175 ((looking-at wl-highlight-citation-prefix-regexp)
1176 (setq prefix (buffer-substring (point)
1178 (setq pair (assoc prefix prefix-face-alist))
1180 (setq prefix-face-alist
1181 (append prefix-face-alist
1187 (% (length prefix-face-alist)
1189 wl-highlight-citation-face-list))
1190 wl-highlight-citation-face-list)))))))
1191 (unless wl-highlight-highlight-citation-too
1192 (goto-char (match-end 0)))
1193 (setq current (cdr pair)))
1194 ((null wl-highlight-citation-header-regexp)
1196 ((looking-at wl-highlight-citation-header-regexp)
1197 (setq current 'wl-highlight-message-citation-header)
1198 (setq end (match-end 0)))
1199 (t (setq current nil)))
1202 (forward-line 1) ; this is to put the \n in the face too
1203 (let ();(inhibit-read-only t))
1204 (put-text-property p (or end (point))
1209 (run-hooks 'wl-highlight-message-hook))))))
1212 ;; highlight-mouse-line for folder mode
1214 (defun wl-highlight-folder-mouse-line ()
1216 (let* ((end (save-excursion (end-of-line) (point)))
1218 (re-search-forward "[^ ]" end t)
1220 (inhibit-read-only t))
1221 (put-text-property beg end 'mouse-face 'highlight)))
1223 ;;; wl-highlight.el ends here