* modb-standard.el (modb-standard-digest-flags): Abolish.
authorteranisi <teranisi>
Tue, 31 Aug 2004 13:22:26 +0000 (13:22 +0000)
committerteranisi <teranisi>
Tue, 31 Aug 2004 13:22:26 +0000 (13:22 +0000)
(elmo-msgdb-list-flagged): Use elmo-digest-flags instead.

* elmo-vars.el (elmo-digest-flags): New variable.
(elmo-preserved-flags): Moved from elmo-flag.el.

* elmo-imap4.el (elmo-imap4-flag-to-imap-search-key): New function.
(elmo-imap4-flag-to-imap-criteria): Ditto.
(elmo-imap4-folder-list-flagged): Use it.

* elmo-flag.el (elmo-preserved-flags): Moved to elmo-vars.el.

elmo/ChangeLog
elmo/elmo-flag.el
elmo/elmo-imap4.el
elmo/elmo-vars.el
elmo/modb-standard.el

index f755d10..903900a 100644 (file)
@@ -1,5 +1,17 @@
 2004-08-31  Yuuichi Teranishi  <teranisi@gohome.org>
 
+       * modb-standard.el (modb-standard-digest-flags): Abolish.
+       (elmo-msgdb-list-flagged): Use elmo-digest-flags instead.
+
+       * elmo-vars.el (elmo-digest-flags): New variable.
+       (elmo-preserved-flags): Moved from elmo-flag.el.
+
+       * elmo-imap4.el (elmo-imap4-flag-to-imap-search-key): New function.
+       (elmo-imap4-flag-to-imap-criteria): Ditto.
+       (elmo-imap4-folder-list-flagged): Use it.
+
+       * elmo-flag.el (elmo-preserved-flags): Moved to elmo-vars.el.
+
        * elmo.el (elmo-folder-count-flags): Changed return value.
 
        * elmo-flag.el (elmo-preserved-flags): New variable.
index 781b31b..f667d17 100644 (file)
 (eval-when-compile (require 'cl))
 
 ;;; Code:
-(defcustom elmo-preserved-flags '(answered cached new unread)
-  "Reserved flags which are not treated as global."
-  :type '(repeat (symbol :tag "flag")))
-
 (defcustom elmo-global-flag-list '(important)
   "A list of flag symbol which is managed globally by the flag folder."
   :type '(repeat symbol)
index 8b0296b..4bfcebe 100644 (file)
@@ -763,28 +763,50 @@ Returns response value if selecting folder succeed. "
     (t
      (member "\\*" (elmo-imap4-session-flags-internal session)))))
 
+(defun elmo-imap4-flag-to-imap-search-key (flag)
+  (case flag
+    (read "seen")
+    (unread "unseen")
+    (important "flagged")
+    (answered "answered")
+    (new "new")
+    (t (concat
+       "keyword "
+       (or (car (cdr (assq flag elmo-imap4-flag-specs)))
+           (symbol-name flag))))))
+
+(defun elmo-imap4-flag-to-imap-criteria (flag)
+  (case flag
+    ((any digest)
+     (let ((criteria "flagged")
+          (global-flags (delq 'important (elmo-get-global-flags t t))))
+       (dolist (flag (delete 'new
+                            (delete 'cached
+                                    (copy-sequence
+                                     (case flag
+                                       (any
+                                        elmo-preserved-flags)
+                                       (digest
+                                        elmo-digest-flags))))))
+        (setq criteria (concat "or "
+                               (elmo-imap4-flag-to-imap-search-key flag)
+                               " "
+                               criteria)))
+       (while global-flags
+        (setq criteria (concat "or keyword "
+                               (symbol-name (car global-flags))
+                               " "
+                               criteria))
+        (setq global-flags (cdr global-flags)))
+       criteria))
+    (t
+     (elmo-imap4-flag-to-imap-search-key flag))))
+
 (defun elmo-imap4-folder-list-flagged (folder flag)
   "List flagged message numbers in the FOLDER.
 FLAG is one of the `unread', `read', `important', `answered', `any'."
   (let ((session (elmo-imap4-get-session folder))
-       (criteria (case flag
-                   (read "seen")
-                   (unread "unseen")
-                   (important "flagged")
-                   (answered "answered")
-                   (new "new")
-                   (any "or answered or unseen flagged")
-                   (digest "or unseen flagged")
-                   (t (concat "keyword " (capitalize (symbol-name flag)))))))
-    ;; Add search keywords
-    (when (or (eq flag 'digest)(eq flag 'any))
-      (let ((flags (delq 'important (elmo-get-global-flags t t))))
-       (while flags
-         (setq criteria (concat "or keyword "
-                                (symbol-name (car flags))
-                                " "
-                                criteria))
-         (setq flags (cdr flags)))))
+       (criteria (elmo-imap4-flag-to-imap-criteria flag)))
     (if (elmo-imap4-session-flag-available-p session flag)
        (progn
          (elmo-imap4-session-select-mailbox
index 80d5380..0e887af 100644 (file)
   :prefix "elmo-"
   :group 'elmo)
 
+(defcustom elmo-digest-flags '(unread)
+  "Flags which are treated as `digest'."
+  :type '(repeat (symbol :tag "flag"))
+  :group 'elmo)
+
+(defcustom elmo-preserved-flags '(answered cached new unread)
+  "Reserved flags which are not treated as global."
+  :type '(repeat (symbol :tag "flag"))
+  :group 'elmo)
+
 ;; Message Database
 
 (defcustom elmo-msgdb-default-type 'legacy
index f538ea6..0f90e29 100644 (file)
@@ -49,9 +49,6 @@
 (defvar modb-standard-msgid-filename "msgid"
   "Message number <=> Message-Id database.")
 
-(defvar modb-standard-digest-flags '(unread)
-  "Flags which are listed as `digest'.")
-
 (eval-and-compile
   (luna-define-class modb-standard (modb-generic)
                     (number-list       ; sorted list of message numbers.
            (setq matched (cons (car entry) matched))))
        (modb-standard-flag-map msgdb)))
       (digest
-       (let ((flags (append modb-standard-digest-flags
+       (let ((flags (append elmo-digest-flags
                            (elmo-get-global-flags t t))))
         (mapatoms
          (lambda (atom)