-(defsubst elmo-folder-search-fast (folder condition numbers)
- "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
- ((string= (elmo-filter-value condition) "unread")
- (elmo-folder-list-unreads folder))
- ((string= (elmo-filter-value condition) "important")
- (elmo-folder-list-importants folder))
- ((string= (elmo-filter-value condition) "answered")
- (elmo-folder-list-answereds folder))
- ((string= (elmo-filter-value condition) "digest")
- (nconc (elmo-folder-list-unreads folder)
- (elmo-folder-list-importants folder)))
- ((string= (elmo-filter-value condition) "any")
- (nconc (elmo-folder-list-unreads folder)
- (elmo-folder-list-importants folder)
- (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))
-