-(defsubst elmo-localdir-field-primitive-condition-match (spec
- condition
- number
- number-list)
- (let (result)
- (goto-char (point-min))
- (cond
- ((string= (elmo-filter-key condition) "last")
- (setq result (<= (length (memq number number-list))
- (string-to-int (elmo-filter-value condition)))))
- ((string= (elmo-filter-key condition) "first")
- (setq result (< (- (length number-list)
- (length (memq number number-list)))
- (string-to-int (elmo-filter-value condition)))))
- (t
- (elmo-set-work-buf
- (as-binary-input-file (insert-file-contents
- (expand-file-name
- (int-to-string number)
- (elmo-localdir-get-folder-directory spec))))
- (elmo-set-buffer-multibyte default-enable-multibyte-characters)
- ;; Should consider charset?
- (decode-mime-charset-region (point-min)(point-max) elmo-mime-charset)
- (setq result
- (elmo-buffer-field-primitive-condition-match
- condition number number-list)))))
- (if (eq (elmo-filter-type condition) 'unmatch)
- (setq result (not result)))
- result))
-
-(defun elmo-localdir-field-condition-match (spec condition number number-list)
- (cond
- ((vectorp condition)
- (elmo-localdir-field-primitive-condition-match
- spec condition number number-list))
- ((eq (car condition) 'and)
- (and (elmo-localdir-field-condition-match
- spec (nth 1 condition) number number-list)
- (elmo-localdir-field-condition-match
- spec (nth 2 condition) number number-list)))
- ((eq (car condition) 'or)
- (or (elmo-localdir-field-condition-match
- spec (nth 1 condition) number number-list)
- (elmo-localdir-field-condition-match
- spec (nth 2 condition) number number-list)))))
-
-(defun elmo-localdir-search (spec condition &optional from-msgs)
- (let* ((msgs (or from-msgs (elmo-localdir-list-folder spec)))
- (num (length msgs))
- (i 0)
- last cur number-list case-fold-search ret-val)
- (cond
- ;; short cut.
- ((and (vectorp condition)
- (string= (elmo-filter-key condition) "last"))
- (nthcdr (max (- (length msgs)
- (string-to-int (elmo-filter-value condition)))
- 0)
- msgs))
- ((and (vectorp condition)
- (string= (elmo-filter-key condition) "first"))
- (let ((rest (nthcdr (string-to-int (elmo-filter-value condition) )
- msgs)))
- (mapcar '(lambda (x)
- (delete x msgs)) rest))
- msgs)
- (t
- (setq number-list msgs)
- (while msgs
- (if (elmo-localdir-field-condition-match spec condition
- (car msgs) number-list)
- (setq ret-val (cons (car msgs) ret-val)))
- (when (> num elmo-display-progress-threshold)
- (setq i (1+ i))
- (setq cur (/ (* i 100) num))
- (unless (eq cur last)
- (elmo-display-progress
- 'elmo-localdir-search "Searching..."
- cur)
- (setq last cur)))
- (setq msgs (cdr msgs)))
- (nreverse ret-val)))))
-
-;;; (localdir, maildir, localnews) -> localdir
-(defun elmo-localdir-copy-msgs (dst-spec msgs src-spec
- &optional loc-alist same-number)
- (let ((dst-dir
- (elmo-localdir-get-folder-directory dst-spec))
- (next-num (1+ (car (elmo-localdir-max-of-folder dst-spec)))))
- (while msgs
- (elmo-copy-file
- ;; src file
- (elmo-call-func src-spec "get-msg-filename" (car msgs) loc-alist)
- ;; dst file
- (expand-file-name (int-to-string
- (if same-number (car msgs) next-num))
- dst-dir))
- (if (and (setq msgs (cdr msgs))
- (not same-number))
- (setq next-num
- (if (and (eq (car dst-spec) 'localdir)
- (elmo-localdir-locked-p))
- ;; MDA is running.
- (1+ (car (elmo-localdir-max-of-folder dst-spec)))
- (1+ next-num)))))
- t))
-
-(defun elmo-localdir-pack-number (spec msgdb arg)
- (let ((dir (elmo-localdir-get-folder-directory spec))
- (onum-alist (elmo-msgdb-get-number-alist msgdb))
- (omark-alist (elmo-msgdb-get-mark-alist msgdb))
- (new-number 1) ; first ordinal position in localdir
- flist onum mark new-mark-alist total)
+(defsubst elmo-localdir-field-condition-match (folder condition
+ number number-list)
+ (elmo-file-field-condition-match
+ (expand-file-name (int-to-string number)
+ (elmo-localdir-folder-directory-internal folder))
+ condition number number-list))
+
+(luna-define-method elmo-folder-pack-numbers ((folder elmo-localdir-folder))
+ (let* ((dir (elmo-localdir-folder-directory-internal folder))
+ (msgdb (elmo-folder-msgdb folder))
+ (onum-alist (elmo-msgdb-get-number-alist msgdb))
+ (omark-alist (elmo-msgdb-get-mark-alist msgdb))
+ (new-number 1) ; first ordinal position in localdir
+ flist onum mark new-mark-alist total)