;; -*- scheme -*-

(add-filter-rule!
 ;;
 ;; Refile a mail from "foo@example.jp" to "from/foo" folder.
 ;;
 '(from
   ("foo@example.jp" "from/foo"))

 ;;
 ;; Refile a mail to "admin@example.com" to "admin" folder.
 ;;
 '(to/cc
   ("admin@example.com" "admin"))

 ;;
 ;; Refile a mail from a mailing list according to List-Id header.
 ;; e.g. "List-Id: <ml.example.jp>" => "ml/ml.example.jp"
 ;;
 '(list-id
   (#/<([-.\w]+)>/  "ml/\\1"))

 ;;
 ;; Refile a mail from a mailing list according to X-ML-Name header.
 ;; e.g. "X-ML-Name: foo-ml" => "ml/foo-ml"
 ;;
 '(x-ml-name
   (#/([-.\w]+)/  "ml/\\1"))

 ;;
 ;; Refile a mail from satoru@example.jp or satoru@example.org
 ;; to "from/satoru" folder.
 ;;
 '(from
   (("satoru@example.jp" "satoru@example.org") "from/satoru")))

;; Replace unsafe characters with `-' in match data.
(set-match-data-replace-rule! '(#/[^a-zA-Z0-9_-]/ "-"))

;; Filter spam mails
;; (add-bayesian-filter-rule!)
