diff -u -p /home/daniel/tmp/t/gnus-sieve.el.orig /home/daniel/tmp/t/gnus-sieve.el --- /home/daniel/tmp/t/gnus-sieve.el.orig 2009-12-04 00:18:17.978172193 +1100 +++ /home/daniel/tmp/t/gnus-sieve.el 2009-12-04 00:31:32.797180020 +1100 @@ -205,6 +205,31 @@ test as the condition and { fileinto \"g If CROSSPOST is nil, each conditional body contains a \"stop\" command which stops execution after a match is found. +The function `gnus-sieve-script-one' generates the actual commands, +while this provides the overall structure and iteration. + +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 ((spec (gnus-sieve-script-one (gnus-info-group info) crosspost))) + (when spec + (push spec script))))) + (mapconcat 'identity script "\n"))) + +(defun gnus-sieve-script-one (group &optional crosspost) + "Generate a single Sieve command for a single Gnus GROUP, +passed as an object. Only groups having a `sieve' parameter have +a command generated; `nil' is returned otherwise. + +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\") @@ -216,22 +241,16 @@ group parameter, (gnus-sieve-script) res } 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"))) + (let ((spec (gnus-group-find-parameter group 'sieve t))) + (when spec + (concat (format "# %s: %s\n" (gnus-group-real-name group) spec) + "if " (gnus-sieve-test spec) " {\n" + "\tfileinto \"" (gnus-group-real-name group) "\";\n" + (if crosspost + "" + "\tstop;\n") + "}")))) + (provide 'gnus-sieve) Diff finished. Fri Dec 4 00:31:54 2009