ptexinfmt.el; Fix last change
[elisp/wanderlust.git] / wl / wl-highlight.el
index da9c23c..c2fd339 100644 (file)
@@ -1,6 +1,6 @@
 ;;; wl-highlight.el --- Hilight modules for Wanderlust.
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
 ;;  Yuuichi Teranishi <teranisi@gohome.org>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 
 ;; important messages
 
+(wl-defface wl-highlight-summary-flagged-face
+  '((((type tty)
+      (background dark))
+     (:foreground "magenta"))
+    (((class color)
+      (background dark))
+     (:foreground "orange"))
+    (((class color)
+      (background light))
+     (:foreground "purple")))
+  "Face used for displaying flagged messages."
+  :group 'wl-summary-faces
+  :group 'wl-faces)
+
 (wl-defface wl-highlight-summary-new-face
   '(
     (((type tty)
   :group 'wl-summary-faces
   :group 'wl-faces)
 
+(wl-defface wl-highlight-summary-killed-face
+  '((((type tty)
+      (background dark))
+     (:foreground "blue"))
+    (((class color)
+      (background dark))
+     (:foreground "gray"))
+    (((class color))
+     (:foreground "LightSlateGray")))
+  "Face used for displaying killed messages."
+  :group 'wl-summary-faces
+  :group 'wl-faces)
+
 (wl-defface wl-highlight-summary-displaying-face
   '((t
      (:underline t :bold t)))
   :group 'wl-summary-faces
   :group 'wl-faces)
 
-;; answered 
+;; answered
 (wl-defface wl-highlight-summary-answered-face
   '((((type tty)
       (background dark))
       (background dark))
      (:foreground "cyan"))
     (((class color)
-      (background dark))
-     (:foreground "SkyBlue"))
-    (((class color)
       (background light))
-     (:foreground "SteelBlue")))
+     (:foreground "SteelBlue" :background "#d9ffd9"))
+    (((class color)
+      (background dark))
+     (:foreground "SkyBlue" :background "#004400")))
   "Face used for displaying demo."
   :group 'wl-faces)
 
   :group 'wl-message-faces
   :group 'wl-faces)
 
-(defvar wl-highlight-folder-opened-regexp " *\\(\\[\\-\\]\\)")
-(defvar wl-highlight-folder-closed-regexp " *\\(\\[\\+\\]\\)")
+(defvar wl-highlight-folder-opened-regexp "^ *\\(\\[\\-\\]\\)")
+(defvar wl-highlight-folder-closed-regexp "^ *\\(\\[\\+\\]\\)")
 (defvar wl-highlight-folder-leaf-regexp "[ ]*\\([-%\\+]\\)\\(.*\\):.*$")
 
 (defvar wl-highlight-citation-face-list
     wl-highlight-message-cited-text-9
     wl-highlight-message-cited-text-10))
 
-(defmacro wl-delete-all-overlays ()
+(defun wl-delete-all-overlays ()
   "Delete all momentary overlays."
-  '(let ((overlays (overlays-in (point-min) (point-max)))
-        overlay)
-     (while (setq overlay (car overlays))
-       (if (overlay-get overlay 'wl-momentary-overlay)
-          (delete-overlay overlay))
-       (setq overlays (cdr overlays)))))
+  (let ((overlays (overlays-in (point-min) (point-max)))
+       overlay)
+    (while (setq overlay (car overlays))
+      (if (overlay-get overlay 'wl-momentary-overlay)
+         (delete-overlay overlay))
+      (setq overlays (cdr overlays)))))
 
 (defun wl-highlight-summary-displaying ()
   (interactive)
              (put-text-property bol (match-end 0) 'face face)))
        (put-text-property bol eol 'face text-face)))))
 
-(defsubst wl-highlight-summary-line-face-spec (flags temp-mark indent)
+(defsubst wl-highlight-get-face-by-name (format &rest args)
+  (let ((face (intern (apply #'format format args))))
+    (and (find-face face)
+        face)))
+
+(defsubst wl-highlight-summary-line-face-spec (status temp-mark indent)
   "Return a cons cell of (face . argument)."
-  (let (action)
-    (if (setq action (assoc temp-mark wl-summary-mark-action-list))
-       (cons (nth 5 action) (nth 2 action))
-      (cond
-       ((and (string= temp-mark wl-summary-score-over-mark)
-            (or (memq 'new flags) (memq 'unread flags)))
-       '(wl-highlight-summary-high-unread-face))
-       ((and (string= temp-mark wl-summary-score-below-mark)
-            (or (memq 'new flags) (memq 'unread flags)))
-       '(wl-highlight-summary-low-unread-face))
-       ((let ((priorities wl-summary-persistent-mark-priority-list)
-             (fl wl-summary-flag-alist)
-             face result global-flags)
-         (while (and (null result) priorities)
-           (if (and (eq (car priorities) 'flag)
-                    (setq global-flags
-                          (elmo-get-global-flags flags 'ignore-preserved)))
-               (while fl
-                 (when (memq (car (car fl)) global-flags)
-                   (setq result
-                         (progn
-                           (setq face
-                                 (intern (format
-                                          "wl-highlight-summary-%s-flag-face"
-                                          (car (car fl)))))
-                           (when (find-face face)
-                             (list face)))
-                         fl nil))
-                 (setq fl (cdr fl)))
-             (when (memq (car priorities) flags)
+  (or (let (action)
+       (and (setq action (assoc temp-mark wl-summary-mark-action-list))
+            (cons (nth 5 action) (nth 2 action))))
+      (let ((flags (elmo-message-status-flags status)))
+       (cond
+        ((and (string= temp-mark wl-summary-score-over-mark)
+              (or (memq 'new flags) (memq 'unread flags)))
+         '(wl-highlight-summary-high-unread-face))
+        ((and (string= temp-mark wl-summary-score-below-mark)
+              (or (memq 'new flags) (memq 'unread flags)))
+         '(wl-highlight-summary-low-unread-face))
+        ((let ((priorities wl-summary-persistent-mark-priority-list)
+               (fl wl-summary-flag-alist)
+               face result global-flags)
+           (while (and (null result) priorities)
+             (cond
+              ((eq (car priorities) 'killed)
+               (when (elmo-message-status-killed-p status)
+                 (setq result '(wl-highlight-summary-killed-face))))
+              ((eq (car priorities) 'flag)
+               (when (setq global-flags
+                           (elmo-get-global-flags flags 'ignore-preserved))
+                 (while fl
+                   (when (memq (car (car fl)) global-flags)
+                     (setq result
+                           (list (or (wl-highlight-get-face-by-name
+                                      "wl-highlight-summary-%s-flag-face"
+                                      (car (car fl)))
+                                     'wl-highlight-summary-flagged-face))
+                           fl nil))
+                   (setq fl (cdr fl)))
+                 (unless result
+                   (setq result (list 'wl-highlight-summary-flagged-face)))))
+              ((memq (car priorities) flags)
                (setq result
-                     (progn (setq face
-                                  (intern (format
-                                           "wl-highlight-summary-%s-face"
-                                           (car priorities))))
-                            (if (find-face face)
-                                (list face)
-                              (list 'wl-summary-persistent-mark-face))))))
-           (setq priorities (cdr priorities)))
-         result))
-       ((string= temp-mark wl-summary-score-below-mark)
-       '(wl-highlight-summary-low-read-face))
-       ((string= temp-mark wl-summary-score-over-mark)
-       '(wl-highlight-summary-high-read-face))
-       (t (if indent
-             '(wl-highlight-summary-normal-face)
-           '(wl-highlight-summary-thread-top-face)))))))
+                     (list (or (wl-highlight-get-face-by-name
+                                "wl-highlight-summary-%s-face"
+                                (car priorities))
+                               'wl-summary-persistent-mark-face)))))
+             (setq priorities (cdr priorities)))
+           result))
+        ((string= temp-mark wl-summary-score-below-mark)
+         '(wl-highlight-summary-low-read-face))
+        ((string= temp-mark wl-summary-score-over-mark)
+         '(wl-highlight-summary-high-read-face))
+        (t (if indent
+               '(wl-highlight-summary-normal-face)
+             '(wl-highlight-summary-thread-top-face)))))))
 
 (autoload 'elmo-flag-folder-referrer "elmo-flag")
 (defun wl-highlight-flag-folder-help-echo (folder number)
                             message
                             string)))))
 
-(defun wl-highlight-summary-line-string (number line flags temp-mark indent)
+(defun wl-highlight-summary-line-string (number line status temp-mark indent)
   (let ((fsymbol (car (wl-highlight-summary-line-face-spec
-                      flags
+                      status
                       temp-mark
                       (> (length indent) 0)))))
     (put-text-property 0 (length line) 'face fsymbol line))
   (when wl-highlight-summary-line-help-echo-alist
     (wl-highlight-summary-line-help-echo number 0 (length line) line)))
 
-(defun wl-highlight-summary-current-line (&optional number flags)
+(defun wl-highlight-summary-current-line (&optional number status)
   (interactive)
   (save-excursion
     (let ((inhibit-read-only t)
        (beginning-of-line)
        (setq bol (point))
        (setq spec (wl-highlight-summary-line-face-spec
-                   (or flags
-                       (elmo-message-flags wl-summary-buffer-elmo-folder
-                                           number))
+                   (or status (wl-summary-message-status number))
                    (wl-summary-temp-mark number)
                    (wl-thread-entity-get-parent-entity
                     (wl-thread-get-entity number))))