;;; elmo-filter.el -- Filtered Folder Interface for ELMO.
-;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
;; Author: Yuuichi Teranishi <teranisi@gohome.org>
;; Keywords: mail, net news
-;; Time-stamp: <00/03/13 18:58:42 teranisi>
;; This file is part of ELMO (Elisp Library for Message Orchestration).
;;
(require 'elmo-msgdb)
-(defun elmo-filter-msgdb-create (spec numlist new-mark already-mark
+(defun elmo-filter-msgdb-create (spec numlist new-mark already-mark
seen-mark important-mark seen-list)
(if (eq (nth 2 spec) 'partial)
(elmo-msgdb-create (nth 2 spec)
- numlist
+ numlist
new-mark
already-mark
seen-mark important-mark seen-list)
seen-mark important-mark seen-list)))
(defun elmo-filter-msgdb-create-as-numlist (spec numlist new-mark already-mark
- seen-mark important-mark
+ seen-mark important-mark
seen-list)
(elmo-msgdb-create-as-numlist (nth 2 spec)
numlist
(elmo-call-func (nth 2 spec) "delete-msgs" msgs))
(defun elmo-filter-list-folder (spec)
- (let ((filter (nth 1 spec))
- (folder (nth 2 spec))
- msgs)
- (cond
- ((vectorp filter)
- (cond ((string= (elmo-filter-key filter)
- "last")
- (setq msgs (elmo-list-folder folder))
- (nthcdr (max (- (length msgs)
- (string-to-int (elmo-filter-value filter)))
- 0)
- msgs))
- ((string= (elmo-filter-key filter)
- "first")
- (setq msgs (elmo-list-folder folder))
- (let ((rest (nthcdr (string-to-int (elmo-filter-value filter) )
- msgs)))
- (mapcar '(lambda (x)
- (delete x msgs)) rest))
- msgs)))
- ((listp filter)
- (elmo-search folder filter)))))
-
-(defun elmo-filter-list-folder-unread (spec mark-alist unread-marks)
- (let ((filter (nth 1 spec))
- (folder (nth 2 spec))
- msgs pair)
- (cond
- ((vectorp filter)
- (cond ((string= (elmo-filter-key filter)
- "last")
- (setq msgs (elmo-list-folder-unread folder mark-alist
- unread-marks))
- (nthcdr (max (- (length msgs)
- (string-to-int (elmo-filter-value filter)))
- 0)
- msgs))
- ((string= (elmo-filter-key filter)
- "first")
- (setq msgs (elmo-list-folder-unread folder
- mark-alist
- unread-marks))
- (let ((rest (nthcdr (string-to-int (elmo-filter-value filter) )
- msgs)))
- (mapcar '(lambda (x)
- (delete x msgs)) rest))
- msgs)))
- ((listp filter)
- (elmo-list-filter
- (elmo-search folder filter)
- (elmo-list-folder-unread folder mark-alist unread-marks))))))
-
-(defun elmo-filter-list-folder-important (spec overview)
- (let ((filter (nth 1 spec))
- (folder (nth 2 spec))
- msgs pair)
- (cond
- ((vectorp filter)
- (cond ((string= (elmo-filter-key filter)
- "last")
- (setq msgs (elmo-list-folder-important folder overview))
- (nthcdr (max (- (length msgs)
- (string-to-int (elmo-filter-value filter)))
- 0)
- msgs))
- ((string= (elmo-filter-key filter)
- "first")
- (setq msgs (elmo-list-folder-important folder overview))
- (let ((rest (nthcdr (string-to-int (elmo-filter-value filter) )
- msgs)))
- (mapcar '(lambda (x)
- (delete x msgs)) rest))
- msgs)))
- ((listp filter)
- (elmo-list-filter
- (mapcar
- '(lambda (x) (elmo-msgdb-overview-entity-get-number x))
- overview)
- (elmo-list-folder-important folder overview))))))
+ (elmo-search (nth 2 spec) (nth 1 spec)))
+
+(defun elmo-filter-list-folder-unread (spec number-alist mark-alist
+ unread-marks)
+ (elmo-list-filter
+ (mapcar 'car number-alist)
+ (elmo-list-folder-unread
+ (nth 2 spec) number-alist mark-alist unread-marks)))
+
+(defun elmo-filter-list-folder-important (spec number-alist)
+ (elmo-list-filter
+ (mapcar 'car number-alist)
+ (elmo-list-folder-important (nth 2 spec) number-alist)))
+
+(defun elmo-filter-folder-diff (spec folder &optional number-list)
+ (if (or (elmo-multi-p folder)
+ (not (and (vectorp (nth 1 spec))
+ (string-match "^last$"
+ (elmo-filter-key (nth 1 spec))))))
+ (cons nil (cdr (elmo-folder-diff (nth 2 spec))))
+ (elmo-generic-folder-diff spec folder number-list)))
(defun elmo-filter-max-of-folder (spec)
(elmo-max-of-folder (nth 2 spec)))
(defun elmo-filter-create-folder (spec)
(elmo-create-folder (nth 2 spec)))
-(defun elmo-filter-search (spec condition &optional numlist)
+(defun elmo-filter-search (spec condition &optional from-msgs)
;; search from messages in this folder
- (elmo-list-filter
- numlist
- (elmo-call-func (nth 2 spec) "search" condition
- (elmo-filter-list-folder spec))))
+ (elmo-list-filter
+ from-msgs
+ (elmo-search (nth 2 spec) condition
+ (elmo-filter-list-folder spec))))
(defun elmo-filter-use-cache-p (spec number)
(elmo-call-func (nth 2 spec) "use-cache-p" number))
(defun elmo-filter-server-diff (spec)
(elmo-call-func (nth 2 spec) "server-diff"))
-(provide 'elmo-filter)
+(require 'product)
+(product-provide (provide 'elmo-filter) (require 'elmo-version))
;;; elmo-filter.el ends here