Function: gnus-sieve-script
gnus-sieve-script is a byte-compiled function defined in
gnus-sieve.el.gz.
Signature
(gnus-sieve-script &optional METHOD CROSSPOST)
Documentation
Generate a Sieve script based on groups with select method METHOD
(or all groups if nil). Only groups having a sieve parameter are
considered. This parameter should contain an elisp test
(see the documentation of gnus-sieve-test for details). For each
such group, a Sieve IF control structure is generated, having the
test as the condition and { fileinto "group.name"; } as the body.
If CROSSPOST is nil, each conditional body contains a "stop" command which stops execution after a match is found.
For example: If the INBOX.list.sieve group has the
(sieve address "sender" "sieve-admin@extundo.com")
group parameter, (gnus-sieve-script) results in:
if address "sender" "sieve-admin@extundo.com" {
fileinto "INBOX.list.sieve";
}
This is returned as a string.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-sieve.el.gz
(defun gnus-sieve-script (&optional method crosspost)
"Generate a Sieve script based on groups with select method METHOD
\(or all groups if nil). Only groups having a `sieve' parameter are
considered. This parameter should contain an elisp test
\(see the documentation of gnus-sieve-test for details). For each
such group, a Sieve IF control structure is generated, having the
test as the condition and { fileinto \"group.name\"; } as the body.
If CROSSPOST is nil, each conditional body contains a \"stop\" command
which stops execution after a match is found.
For example: If the INBOX.list.sieve group has the
(sieve address \"sender\" \"sieve-admin@extundo.com\")
group parameter, (gnus-sieve-script) results in:
if address \"sender\" \"sieve-admin@extundo.com\" {
fileinto \"INBOX.list.sieve\";
}
This is returned as a string."
(let* ((newsrc (cdr gnus-newsrc-alist))
script)
(dolist (info newsrc)
(when (or (not method)
(gnus-server-equal method (gnus-info-method info)))
(let* ((group (gnus-info-group info))
(spec (gnus-group-find-parameter group 'sieve t)))
(when spec
(push (concat "if " (gnus-sieve-test spec) " {\n"
"\tfileinto \"" (gnus-group-real-name group) "\";\n"
(if crosspost
""
"\tstop;\n")
"}")
script)))))
(mapconcat #'identity script "\n")))