From: teranisi Date: Mon, 11 Jun 2001 02:00:09 +0000 (+0000) Subject: * elmo-util.el (elmo-file-field-primitive-condition-match): X-Git-Tag: wl-2_6-root~11 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=3626386a239944ca4a730f11acd8dd14c07d84ed;p=elisp%2Fwanderlust.git * elmo-util.el (elmo-file-field-primitive-condition-match): New inline function (Don't fetch file content if "first" or "last"). (elmo-file-field-condition-match): Use elmo-file-field-primitive-condition-match. * elmo-localdir.el (elmo-localdir-field-primitive-condition-match): New inline function. (elmo-localdir-field-condition-match): Use elmo-localdir-field-primitive-condition-match. (elmo-localdir-search): Speed up simple "last" and "first". --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 44735f0..7e45117 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,16 @@ 2001-06-11 Yuuichi Teranishi + * elmo-util.el (elmo-file-field-primitive-condition-match): + New inline function (Don't fetch file content if "first" or "last"). + (elmo-file-field-condition-match): Use + elmo-file-field-primitive-condition-match. + + * elmo-localdir.el (elmo-localdir-field-primitive-condition-match): + New inline function. + (elmo-localdir-field-condition-match): + Use elmo-localdir-field-primitive-condition-match. + (elmo-localdir-search): Speed up simple "last" and "first". + * elmo2.el (elmo-move-msgs): Bind elmo-inhibit-display-retrieval-progress as t while moving messages. diff --git a/elmo/elmo-localdir.el b/elmo/elmo-localdir.el index 6f9a7e4..46b7ebe 100644 --- a/elmo/elmo-localdir.el +++ b/elmo/elmo-localdir.el @@ -358,31 +358,88 @@ (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 diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index 3cd1ac3..e509e3d 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1369,13 +1369,48 @@ Otherwise treat \\ in NEWTEXT string as special: (elmo-buffer-field-condition-match (nth 2 condition) number number-list))))) -(defsubst elmo-file-field-condition-match (file condition number number-list) - (elmo-set-work-buf - (as-binary-input-file (insert-file-contents file)) - (elmo-set-buffer-multibyte default-enable-multibyte-characters) - ;; Should consider charset? - (decode-mime-charset-region (point-min)(point-max) elmo-mime-charset) - (elmo-buffer-field-condition-match condition number number-list))) +(defsubst elmo-file-field-primitive-condition-match (file + 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 file)) + (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-file-field-condition-match (file condition number number-list) + (cond + ((vectorp condition) + (elmo-file-field-primitive-condition-match + file condition number number-list)) + ((eq (car condition) 'and) + (and (elmo-file-field-condition-match + file (nth 1 condition) number number-list) + (elmo-file-field-condition-match + file (nth 2 condition) number number-list))) + ((eq (car condition) 'or) + (or (elmo-file-field-condition-match + file (nth 1 condition) number number-list) + (elmo-file-field-condition-match + file (nth 2 condition) number number-list))))) (defmacro elmo-get-hash-val (string hashtable) (let ((sym (list 'intern-soft string hashtable)))