From: yoichi Date: Sat, 2 Oct 2004 11:53:13 +0000 (+0000) Subject: * elmo-split.el (elmo-split-rule): Update comment. X-Git-Tag: wl-2_12-root~69 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ecd37542c1f4be32915a44284838b6daa2dc7203;p=elisp%2Fwanderlust.git * elmo-split.el (elmo-split-rule): Update comment. (elmo-split-address-equal): Allow 2nd argument to be a list. (elmo-split-address-match): Ditto. (elmo-split-equal): Ditto. (elmo-split-match): Ditto. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index ed16e37..3e767ca 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,11 @@ +2004-10-02 Yoichi NAKAYAMA + + * elmo-split.el (elmo-split-rule): Update comment. + (elmo-split-address-equal): Allow 2nd argument to be a list. + (elmo-split-address-match): Ditto. + (elmo-split-equal): Ditto. + (elmo-split-match): Ditto. + 2004-09-29 Yuuichi Teranishi * elmo.el (elmo-folder-append-buffer): Fix docstring. diff --git a/elmo/elmo-split.el b/elmo/elmo-split.el index 0de97b0..310f031 100644 --- a/elmo/elmo-split.el +++ b/elmo/elmo-split.el @@ -67,6 +67,9 @@ FIELD-NAME is a symbol of the field name. VALUE can contain \\& and \\N which will substitute from matching \\(\\) patterns in the previous VALUE. +FIELD-NAME can be a list of field names, return true if any of the fields +satisfy the condition. + 2. Functions which accept an argument SIZE, SIZE is some number. `<' ... True if the size of the message is less than SIZE. @@ -177,36 +180,42 @@ It can be some ACTION as in `elmo-split-rule'." (defun elmo-split-< (buffer size) (< (buffer-size buffer) size)) -(defun elmo-split-address-equal (buffer field value) +(defun elmo-split-address-equal (buffer field-or-fields value) (with-current-buffer buffer - (let ((addrs (mapcar - 'std11-address-string - (std11-parse-addresses-string - (std11-field-body (symbol-name field))))) - (case-fold-search t) - result) - (while addrs - (when (string-match (concat "^" - (regexp-quote value) - "$") (car addrs)) - (setq addrs nil - result t)) - (setq addrs (cdr addrs))) + (let (result) + (dolist (field (if (listp field-or-fields) + field-or-fields + (list field))) + (let ((addrs (mapcar + 'std11-address-string + (std11-parse-addresses-string + (std11-field-body (symbol-name field))))) + (case-fold-search t)) + (while addrs + (when (string-match (concat "^" + (regexp-quote value) + "$") (car addrs)) + (setq addrs nil + result t)) + (setq addrs (cdr addrs))))) result))) -(defun elmo-split-address-match (buffer field value) +(defun elmo-split-address-match (buffer field-or-fields value) (with-current-buffer buffer - (let ((addrs (mapcar - 'std11-address-string - (std11-parse-addresses-string - (std11-field-body (symbol-name field))))) - result) - (while addrs - (when (string-match value (car addrs)) - (setq elmo-split-match-string-internal (car addrs) - addrs nil - result t)) - (setq addrs (cdr addrs))) + (let (result) + (dolist (field (if (listp field-or-fields) + field-or-fields + (list field))) + (let ((addrs (mapcar + 'std11-address-string + (std11-parse-addresses-string + (std11-field-body (symbol-name field)))))) + (while addrs + (when (string-match value (car addrs)) + (setq elmo-split-match-string-internal (car addrs) + addrs nil + result t)) + (setq addrs (cdr addrs))))) result))) (defun elmo-split-fetch-decoded-field (entity field-name) @@ -215,14 +224,20 @@ It can be some ACTION as in `elmo-split-rule'." (when field-body (mime-decode-field-body field-body sym 'plain)))) -(defun elmo-split-equal (buffer field value) +(defun elmo-split-equal (buffer field-or-fields value) (with-current-buffer buffer - (let ((field-value (and - elmo-split-message-entity - (elmo-split-fetch-decoded-field - elmo-split-message-entity - (symbol-name field))))) - (equal field-value value)))) + (let (result) + (dolist (field (if (listp field-or-fields) + field-or-fields + (list field))) + (let ((field-value (and + elmo-split-message-entity + (elmo-split-fetch-decoded-field + elmo-split-message-entity + (symbol-name field))))) + (setq result (or result + (equal field-value value))))) + result))) (defun elmo-split-spam-p (buffer &rest plist) (require 'elmo-spam) @@ -230,15 +245,21 @@ It can be some ACTION as in `elmo-split-rule'." buffer (plist-get plist :register))) -(defun elmo-split-match (buffer field value) +(defun elmo-split-match (buffer field-or-fields value) (with-current-buffer buffer - (let ((field-value (and elmo-split-message-entity - (elmo-split-fetch-decoded-field - elmo-split-message-entity - (symbol-name field))))) - (and field-value - (when (string-match value field-value) - (setq elmo-split-match-string-internal field-value)))))) + (let (result) + (dolist (field (if (listp field-or-fields) + field-or-fields + (list field))) + (let ((field-value (and elmo-split-message-entity + (elmo-split-fetch-decoded-field + elmo-split-message-entity + (symbol-name field))))) + (and field-value + (when (string-match value field-value) + (setq result t) + (setq elmo-split-match-string-internal field-value))))) + result))) (defun elmo-split-eval (buffer sexp) (cond