* elmo.el (elmo-folder-search-fast): Return t if condition is not
authorhmurata <hmurata>
Tue, 22 Jul 2003 03:50:09 +0000 (03:50 +0000)
committerhmurata <hmurata>
Tue, 22 Jul 2003 03:50:09 +0000 (03:50 +0000)
treated.
(elmo-folder-search): Follow the change above.

* elmo-util.el (elmo-read-search-condition-internal): Add `Flag'
into the candidates of search field.

elmo/ChangeLog
elmo/elmo-util.el
elmo/elmo.el

index c1aec9b..20591ba 100644 (file)
@@ -1,3 +1,12 @@
+2003-07-22  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elmo.el (elmo-folder-search-fast): Return t if condition is not
+       treated.
+       (elmo-folder-search): Follow the change above.
+
+       * elmo-util.el (elmo-read-search-condition-internal): Add `Flag'
+       into the candidates of search field.
+
 2003-07-21  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * elmo-msgdb.el (elmo-msgdb-set-flag): Overwrite answered flag.
index 57cd392..413aaa9 100644 (file)
@@ -149,7 +149,7 @@ File content is encoded with MIME-CHARSET."
                 (format "%s (%s): " prompt default)
                 (mapcar 'list
                         (append '("AND" "OR"
-                                  "Last" "First"
+                                  "Last" "First" "Flag"
                                   "From" "Subject" "To" "Cc" "Body"
                                   "Since" "Before" "ToCc"
                                   "!From" "!Subject" "!To" "!Cc" "!Body"
@@ -178,6 +178,15 @@ File content is encoded with MIME-CHARSET."
                             elmo-date-descriptions)))
        (concat (downcase field) ":"
                (if (equal value "") default value))))
+     ((string= field "Flag")
+      (setq value (completing-read
+                  (format "Value for '%s': " field)
+                  (mapcar 'list
+                          '("unread" "important" "answered" "digest" "any"))))
+      (unless (string-match (concat "^" elmo-condition-atom-regexp "$")
+                           value)
+       (setq value (prin1-to-string value)))
+      (concat (downcase field) ":" value))
      (t
       (setq value (read-from-minibuffer (format "Value for '%s': " field)))
       (unless (string-match (concat "^" elmo-condition-atom-regexp "$")
index de1fa43..cae7202 100644 (file)
@@ -743,10 +743,15 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
     (elmo-msgdb-rename-path folder new-folder)))
 
 (defsubst elmo-folder-search-fast (folder condition numbers)
-  (when (and numbers
-            (vectorp condition)
-            (member (elmo-filter-key condition) '("first" "last" "mark")))
-    (if (string= (elmo-filter-key condition) "flag")
+  "Search and return list of message numbers.
+Return t if CONDITION is not treated.
+FOLDER is the ELMO folder structure.
+CONDITION is a condition structure for searching.
+NUMBERS is a list of message numbers, messages are searched from the list."
+  (if (and numbers
+          (vectorp condition))
+      (cond
+       ((string= (elmo-filter-key condition) "flag")
        (let ((msgdb (elmo-folder-msgdb folder)))
          ;; msgdb should be synchronized at this point.
          (cond
@@ -762,50 +767,59 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
           ((string= (elmo-filter-value condition) "any")
            (nconc (elmo-folder-list-unreads folder)
                   (elmo-folder-list-importants folder)
-                  (elmo-folder-list-answereds folder)))))
-      (let ((len (length numbers))
-           (lastp (string= (elmo-filter-key condition) "last"))
-           (value (string-to-number (elmo-filter-value condition))))
-       (when (eq (elmo-filter-type condition) 'unmatch)
-         (setq lastp (not lastp)
-               value  (- len value)))
-       (if lastp
-           (nthcdr (max (- len value) 0) numbers)
-         (when (> value 0)
-           (let ((last (nthcdr (1- value) numbers)))
-             (when last
-               (setcdr last nil))
-             numbers)))))))
+                  (elmo-folder-list-answereds folder))))))
+       ((member (elmo-filter-key condition) '("first" "last"))
+       (let ((len (length numbers))
+             (lastp (string= (elmo-filter-key condition) "last"))
+             (value (string-to-number (elmo-filter-value condition))))
+         (when (eq (elmo-filter-type condition) 'unmatch)
+           (setq lastp (not lastp)
+                 value  (- len value)))
+         (if lastp
+             (nthcdr (max (- len value) 0) numbers)
+           (when (> value 0)
+             (let* ((numbers (copy-sequence numbers))
+                    (last (nthcdr (1- value) numbers)))
+               (when last
+                 (setcdr last nil))
+               numbers)))))
+       (t
+       t))
+    t))
 
 (luna-define-method elmo-folder-search ((folder elmo-folder)
                                        condition
                                        &optional numbers)
-  (let ((numbers (or numbers (elmo-folder-list-messages folder))))
-    (or (elmo-folder-search-fast folder condition numbers)
-       (let ((msgdb (elmo-folder-msgdb folder))
-             (len (length numbers))
-             matched)
-         (when (> len elmo-display-progress-threshold)
-           (elmo-progress-set 'elmo-folder-search len "Searching..."))
-         (unwind-protect
-             (dolist (number numbers)
-               (let (result)
-                 (setq result (elmo-msgdb-match-condition
-                               msgdb
-                               condition
+  (let ((numbers (or numbers (elmo-folder-list-messages folder)))
+       results)
+    (if (listp (setq results (elmo-folder-search-fast folder
+                                                     condition
+                                                     numbers)))
+       results
+      (let ((msgdb (elmo-folder-msgdb folder))
+           (len (length numbers))
+           matched)
+       (when (> len elmo-display-progress-threshold)
+         (elmo-progress-set 'elmo-folder-search len "Searching..."))
+       (unwind-protect
+           (dolist (number numbers)
+             (let (result)
+               (setq result (elmo-msgdb-match-condition
+                             msgdb
+                             condition
+                             number
+                             numbers))
+               (when (elmo-filter-condition-p result)
+                 (setq result (elmo-message-match-condition
+                               folder
                                number
-                               numbers))
-                 (when (elmo-filter-condition-p result)
-                   (setq result (elmo-message-match-condition
-                                 folder
-                                 number
-                                 condition
-                                 numbers)))
-                 (when result
-                   (setq matched (cons number matched))))
-               (elmo-progress-notify 'elmo-folder-search))
-           (elmo-progress-clear 'elmo-folder-search))
-         (nreverse matched)))))
+                               condition
+                               numbers)))
+               (when result
+                 (setq matched (cons number matched))))
+             (elmo-progress-notify 'elmo-folder-search))
+         (elmo-progress-clear 'elmo-folder-search))
+       (nreverse matched)))))
 
 (luna-define-method elmo-message-match-condition ((folder elmo-folder)
                                                  number condition