(wl-summary-mark-as-read-internal): Fixed the behavior of
[elisp/wanderlust.git] / wl / wl-highlight.el
index df8462c..fa0cdbb 100644 (file)
@@ -1,6 +1,7 @@
 ;;; wl-highlight.el --- Hilight modules for Wanderlust.
 
-;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+;;  Yuuichi Teranishi <teranisi@gohome.org>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 ;; Keywords: mail, net news
         (require 'wl-e21))
        (t
         (require 'wl-mule)))
-  (defun-maybe extent-begin-glyph (a))
-  (defun-maybe delete-extent (a))
-  (defun-maybe make-extent (a b))
-  (defun-maybe set-extent-begin-glyph (a b))
-  (defun-maybe set-extent-end-glyph (a b))
-  (defun-maybe extent-at (a b c d e))
   (defun-maybe wl-dnd-set-drop-target (a b))
   (defun-maybe wl-dnd-set-drag-starter (a b)))
 
   :group 'wl-summary-faces
   :group 'wl-faces)
 
-(wl-defface wl-highlight-summary-deleted-face
+(wl-defface wl-highlight-summary-disposed-face
   '(
     (((type tty)
       (background dark))
     (((class color)
       (background light))
      (:foreground "DarkKhaki")))
+  "Face used for displaying messages mark as disposed."
+  :group 'wl-summary-faces
+  :group 'wl-faces)
+
+(wl-defface wl-highlight-summary-deleted-face
+  '(
+    (((type tty)
+      (background dark))
+     (:foreground "blue"))
+    (((class color)
+      (background dark))
+     (:foreground "SteelBlue"))
+    (((class color)
+      (background light))
+     (:foreground "SteelBlue")))
+  "Face used for displaying messages mark as deleted."
+  :group 'wl-summary-faces
+  :group 'wl-faces)
+
+(wl-defface wl-highlight-summary-prefetch-face
+  '(
+    (((type tty)
+      (background dark))
+     (:foreground "Green"))
+    (((class color)
+      (background dark))
+     (:foreground "DeepSkyBlue"))
+    (((class color)
+      (background light))
+     (:foreground "brown")))
   "Face used for displaying messages mark as deleted."
   :group 'wl-summary-faces
   :group 'wl-faces)
 
+(wl-defface wl-highlight-summary-resend-face
+  '(
+    (((type tty)
+      (background dark))
+     (:foreground "Yellow"))
+    (((class color)
+      (background dark))
+     (:foreground "orange3"))
+    (((class color)
+      (background light))
+     (:foreground "orange3")))
+  "Face used for displaying messages mark as resend."
+  :group 'wl-summary-faces
+  :group 'wl-faces)
+
 (wl-defface wl-highlight-summary-refiled-face
   '(
     (((type tty)
 (defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
 
-(defvar wl-highlight-summary-unread-regexp " *[0-9]+[^0-9]\\(!\\|U\\)")
-(defvar wl-highlight-summary-important-regexp " *[0-9]+[^0-9]\\$")
-(defvar wl-highlight-summary-new-regexp " *[0-9]+[^0-9]N")
-(defvar wl-highlight-summary-deleted-regexp " *[0-9]+D")
-(defvar wl-highlight-summary-refiled-regexp " *[0-9]+o")
-(defvar wl-highlight-summary-copied-regexp " *[0-9]+O")
-(defvar wl-highlight-summary-target-regexp " *[0-9]+\\*")
-;;(defvar wl-highlight-summary-thread-top-regexp " *[0-9]+[^0-9][^0-9]../..\(.*\)..:.. \\[")
-
 (defvar wl-highlight-citation-face-list
   '(wl-highlight-message-cited-text-1
     wl-highlight-message-cited-text-2
        (put-text-property bol eol 'face text-face)))))
 
 (defun wl-highlight-summary-line-string (line mark temp-mark indent)
-  (let (fsymbol)
-    (cond ((and (string= temp-mark "+")
+  (let (fsymbol action)
+    (cond ((and (string= temp-mark wl-summary-score-over-mark)
                (member mark (list elmo-msgdb-unread-cached-mark
                                   elmo-msgdb-unread-uncached-mark
                                   elmo-msgdb-new-mark)))
           (setq fsymbol 'wl-highlight-summary-high-unread-face))
-         ((and (string= temp-mark "-")
+         ((and (string= temp-mark wl-summary-score-below-mark)
                (member mark (list elmo-msgdb-unread-cached-mark
                                   elmo-msgdb-unread-uncached-mark
                                   elmo-msgdb-new-mark)))
           (setq fsymbol 'wl-highlight-summary-low-unread-face))
-         ((string= temp-mark "o")
-          (setq fsymbol 'wl-highlight-summary-refiled-face))
-         ((string= temp-mark "O")
-          (setq fsymbol 'wl-highlight-summary-copied-face))
-         ((string= temp-mark "D")
-          (setq fsymbol 'wl-highlight-summary-deleted-face))
-         ((string= temp-mark "*")
-          (setq fsymbol 'wl-highlight-summary-temp-face))
+         ((setq action (assoc temp-mark wl-summary-mark-action-list))
+          (setq fsymbol (nth 5 action)))
          ((string= mark elmo-msgdb-new-mark)
           (setq fsymbol 'wl-highlight-summary-new-face))
          ((member mark (list elmo-msgdb-unread-cached-mark
           (setq fsymbol 'wl-highlight-summary-answered-face))
          ((or (string= mark elmo-msgdb-important-mark))
           (setq fsymbol 'wl-highlight-summary-important-face))
-         ((string= temp-mark "-")
+         ((string= temp-mark wl-summary-score-below-mark)
           (setq fsymbol 'wl-highlight-summary-low-read-face))
-         ((string= temp-mark "+")
+         ((string= temp-mark wl-summary-score-over-mark)
           (setq fsymbol 'wl-highlight-summary-high-read-face))
          (t (if (zerop (length indent))
                 (setq fsymbol 'wl-highlight-summary-thread-top-face)
   (if wl-use-highlight-mouse-line
       (put-text-property 0 (length line) 'mouse-face 'highlight line)))
 
-(defun wl-highlight-summary-current-line (&optional smark regexp temp-too)
+(defun wl-highlight-summary-current-line ()
   (interactive)
   (save-excursion
     (let ((inhibit-read-only t)
          (case-fold-search nil) temp-mark status-mark
          (deactivate-mark nil)
-         fregexp fsymbol bol eol matched thread-top looked-at dest ds)
+         fsymbol action bol eol matched thread-top looked-at dest ds)
       (end-of-line)
       (setq eol (point))
       (beginning-of-line)
       (setq bol (point))
-      (if smark
-         (setq status-mark smark)
-       (setq status-mark (wl-summary-persistent-mark)))
-      (when temp-too
-       (setq temp-mark (wl-summary-temp-mark))
-       (cond
-        ((string= temp-mark "*")
-         (setq fsymbol 'wl-highlight-summary-temp-face))
-        ((string= temp-mark "D")
-         (setq fsymbol 'wl-highlight-summary-deleted-face))
-        ((string= temp-mark "O")
-         (setq fsymbol 'wl-highlight-summary-copied-face
-               dest t))
-        ((string= temp-mark "o")
-         (setq fsymbol 'wl-highlight-summary-refiled-face
-               dest t))))
+      (setq status-mark (wl-summary-persistent-mark))
+      (setq temp-mark (wl-summary-temp-mark))
+      (when (setq action (assoc temp-mark wl-summary-mark-action-list))
+       (setq fsymbol (nth 5 action)))
       (if (not fsymbol)
          (cond
-          ((and (string= temp-mark "+")
+          ((and (string= temp-mark wl-summary-score-over-mark)
                 (member status-mark (list elmo-msgdb-unread-cached-mark
                                           elmo-msgdb-unread-uncached-mark
                                           elmo-msgdb-new-mark)))
            (setq fsymbol 'wl-highlight-summary-high-unread-face))
-          ((and (string= temp-mark "-")
+          ((and (string= temp-mark wl-summary-score-below-mark)
                 (member status-mark (list elmo-msgdb-unread-cached-mark
                                           elmo-msgdb-unread-uncached-mark
                                           elmo-msgdb-new-mark)))
           ((string= status-mark elmo-msgdb-important-mark)
            (setq fsymbol 'wl-highlight-summary-important-face))
           ;; score mark
-          ((string= temp-mark "-")
+          ((string= temp-mark wl-summary-score-below-mark)
            (setq fsymbol 'wl-highlight-summary-low-read-face))
-          ((string= temp-mark "+")
+          ((string= temp-mark wl-summary-score-over-mark)
            (setq fsymbol 'wl-highlight-summary-high-read-face))
           ;;
           (t (if (null
                  (setq fsymbol 'wl-highlight-summary-thread-top-face)
                (setq fsymbol 'wl-highlight-summary-normal-face)))))
       (put-text-property bol eol 'face fsymbol)
-      (when dest
-       (put-text-property (next-single-property-change
-                           (next-single-property-change
-                            bol 'wl-summary-destination
-                            nil eol)
-                           'wl-summary-destination nil eol)
-                          eol
-                          'face
-                          'wl-highlight-refile-destination-face))
       (if wl-use-highlight-mouse-line
          (put-text-property bol
-;;; Use bol instead of (1- (match-end 0))
-;;;                         (1- (match-end 0))
                             eol 'mouse-face 'highlight))
-;;;   (put-text-property (match-beginning 3) (match-end 3)
-;;;                     'face 'wl-highlight-thread-indent-face)
-      ;; Dnd stuff.
       (if wl-use-dnd
          (wl-dnd-set-drag-starter bol eol)))))
 
@@ -983,16 +982,7 @@ Faces used:
   wl-highlight-summary-deleted-face     messages mark as deleted
   wl-highlight-summary-refiled-face     messages mark as refiled
   wl-highlight-summary-copied-face      messages mark as copied
-  wl-highlight-summary-new-face         new messages
-
-Variables used:
-  wl-highlight-summary-unread-regexp    matches unread messages
-  wl-highlight-summary-important-regexp matches important messages
-  wl-highlight-summary-deleted-regexp   matches messages mark as deleted
-  wl-highlight-summary-refiled-regexp   matches messages mark as refiled
-  wl-highlight-summary-copied-regexp    matches messages mark as copied
-  wl-highlight-summary-new-regexp       matches new messages
-"
+  wl-highlight-summary-new-face         new messages"
   (if (< end start)
       (let ((s start)) (setq start end end s)))
   (let (lines too-big gc-message e p hend i percent)
@@ -1007,9 +997,7 @@ Variables used:
                  (< (point) end))
        (when (or (not lazy)
                  (null (get-text-property (point) 'face)))
-         (wl-highlight-summary-current-line nil nil
-                                            (or wl-summary-lazy-highlight
-                                                wl-summary-scored)))
+         (wl-highlight-summary-current-line))
        (forward-line 1))
       (unless wl-summary-lazy-highlight
        (message "Highlighting...done")))))
@@ -1017,13 +1005,17 @@ Variables used:
 (defun wl-highlight-summary-window (&optional win beg)
   "Highlight summary window.
 This function is defined for `window-scroll-functions'"
-  (if wl-summary-highlight
-      (with-current-buffer (window-buffer win)
-       (when (eq major-mode 'wl-summary-mode)
-         (wl-highlight-summary (window-start win)
-                               (window-end win)
-                               'lazy)
-         (set-buffer-modified-p nil)))))
+  (when wl-summary-highlight
+    (with-current-buffer (window-buffer win)
+      (when (eq major-mode 'wl-summary-mode)
+       (let ((start (window-start win))
+             (end (condition-case nil
+                      (window-end win t) ;; old emacsen doesn't support 2nd arg.
+                    (error (window-end win)))))
+         (wl-highlight-summary start
+                               end
+                               'lazy))
+       (set-buffer-modified-p nil)))))
 
 (defun wl-highlight-headers (&optional for-draft)
   (let ((beg (point-min))
@@ -1124,8 +1116,7 @@ interpreted as cited text.)"
        (real-end end)
        current  beg
        e p hend)
-    (if too-big
-       nil
+    (unless too-big
       (save-excursion
        (save-restriction
          (widen)
@@ -1154,29 +1145,27 @@ interpreted as cited text.)"
              (goto-char start)
              (while (and (not body-only)
                          (not (eobp)))
-               (cond
-                ((looking-at "^[^ \t\n:]+[ \t]*:")
-                 (put-text-property (match-beginning 0) (match-end 0)
-                                    'face 'wl-highlight-message-headers)
-                 (setq p (match-end 0))
-                 (setq hend (save-excursion (std11-field-end end)))
-                 (cond
-                  ((catch 'match
-                     (let ((regexp-alist wl-highlight-message-header-alist))
-                       (while regexp-alist
-                         (when (save-match-data
-                                 (looking-at (caar regexp-alist)))
-                           (put-text-property p hend 'face
-                                              (cdar regexp-alist))
-                           (throw 'match t))
-                         (setq regexp-alist (cdr regexp-alist)))
-                       (throw 'match nil))))
-                  (t
-                   (put-text-property
-                    p hend 'face 'wl-highlight-message-header-contents)))
-                 (goto-char hend))
-                ;; ignore non-header field name lines
-                (t (forward-line 1))))))
+               (if (looking-at "^[^ \t\n:]+[ \t]*:")
+                   (progn
+                     (put-text-property (match-beginning 0) (match-end 0)
+                                        'face 'wl-highlight-message-headers)
+                     (setq p (match-end 0))
+                     (setq hend (save-excursion (std11-field-end end)))
+                     (or (catch 'match
+                           (let ((regexp-alist wl-highlight-message-header-alist))
+                             (while regexp-alist
+                               (when (save-match-data
+                                       (looking-at (caar regexp-alist)))
+                                 (put-text-property p hend 'face
+                                                    (cdar regexp-alist))
+                                 (throw 'match t))
+                               (setq regexp-alist (cdr regexp-alist)))
+                             (throw 'match nil)))
+                         (put-text-property
+                          p hend 'face 'wl-highlight-message-header-contents))
+                     (goto-char hend))
+                 ;; ignore non-header field name lines
+                 (forward-line 1)))))
          (let (prefix prefix-face-alist pair end)
            (while (not (eobp))
              (cond