X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=elmo%2Felmo-localdir.el;h=46b7ebe7e619afceac9ba60d45b6758c25b534c5;hb=3a4e0ede6f7ecdb73d3c636c5a2fef6d64e8b00a;hp=3b68094a940949aa7e4147eb29a2dce00fd172c9;hpb=9e0f75cd4d9a7b314ca4454c78640bd4de8f631b;p=elisp%2Fwanderlust.git diff --git a/elmo/elmo-localdir.el b/elmo/elmo-localdir.el index 3b68094..46b7ebe 100644 --- a/elmo/elmo-localdir.el +++ b/elmo/elmo-localdir.el @@ -1,8 +1,12 @@ ;;; elmo-localdir.el -- Localdir Interface for ELMO. -;; Copyright 1998,1999,2000 Yuuichi Teranishi +;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi +;; Copyright (C) 1998,1999,2000 Masahiro MURATA +;; Copyright (C) 1999,2000 Kenichi OKADA ;; Author: Yuuichi Teranishi +;; Masahiro MURATA +;; Kenichi OKADA ;; Keywords: mail, net news ;; This file is part of ELMO (Elisp Library for Message Orchestration). @@ -156,7 +160,7 @@ 'elmo-localdir-msgdb-create-as-numlist "Creating msgdb..." (/ (* i 100) len))) (setq numlist (cdr numlist))) - (message "Creating msgdb...done.") + (message "Creating msgdb...done") (list overview number-alist mark-alist)))) (defalias 'elmo-localdir-msgdb-create 'elmo-localdir-msgdb-create-as-numlist) @@ -268,7 +272,7 @@ (progn (delete-file file) t)))) -(defun elmo-localdir-read-msg (spec number outbuf &optional set-mark) +(defun elmo-localdir-read-msg (spec number outbuf &optional msgdb unread) (save-excursion (let* ((number (int-to-string number)) (dir (elmo-localdir-get-folder-directory spec)) @@ -283,7 +287,7 @@ (mapcar '(lambda (msg) (elmo-localdir-delete-msg spec msg)) msgs)) -(defun elmo-localdir-list-folder (spec); called by elmo-localdir-search() +(defun elmo-localdir-list-folder (spec &optional nohide); called by elmo-localdir-search() (elmo-localdir-list-folder-subr spec)) (defun elmo-localdir-max-of-folder (spec) @@ -337,7 +341,7 @@ (defun elmo-localdir-delete-folder (spec) (let* ((dir (elmo-localdir-get-folder-directory spec))) (if (not (file-directory-p dir)) - (error "no such directory: %s" dir) + (error "No such directory: %s" dir) (elmo-delete-directory dir t) t))) @@ -346,39 +350,96 @@ (new (elmo-localdir-get-folder-directory new-spec)) (new-dir (directory-file-name (file-name-directory new)))) (if (not (file-directory-p old)) - (error "no such directory: %s" old) + (error "No such directory: %s" old) (if (file-exists-p new) - (error "already exists directory: %s" new) + (error "Already exists directory: %s" new) (if (not (file-exists-p new-dir)) (elmo-make-directory new-dir)) (rename-file old new) t)))) -(defsubst elmo-localdir-field-condition-match (spec condition - number number-list) - (elmo-file-field-condition-match - (expand-file-name (int-to-string number) - (elmo-localdir-get-folder-directory spec)) - condition - number number-list)) +(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) - number-list case-fold-search ret-val) - (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)) - (elmo-display-progress - 'elmo-localdir-search "Searching..." - (/ (* i 100) num))) - (setq msgs (cdr msgs))) - (nreverse ret-val))) + 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 @@ -440,7 +501,7 @@ new-number mark))) (setq new-number (1+ new-number)) (setq flist (cdr flist))) - (message "Packing...done.") + (message "Packing...done") (list (elmo-msgdb-get-overview msgdb) onum-alist new-mark-alist