annotate lisp/gnus/gnus-mlspl.el @ 36802:7225d251346b

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Wed, 14 Mar 2001 13:26:45 +0000
parents 0ec780720bfe
children 64d8d90d180d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; gnus-mlspl.el --- a group params-based mail splitting mechanism
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
2 ;; Copyright (C) 1998, 1999, 2000
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
3 ;; Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Keywords: news, mail
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
19 ;; along with this program; see the file COPYING. If not, write to
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; Boston, MA 02111-1307, USA.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
33270
93c83ac38c92 2000-11-06 John Wiegley <johnw@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
23 (eval-when-compile (require 'cl))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 (require 'gnus)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 (require 'gnus-sum)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 (require 'gnus-group)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 (require 'nnmail)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 (defvar gnus-group-split-updated-hook nil
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
30 "Hook called just after nnmail-split-fancy is updated by
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
31 gnus-group-split-update.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 (defvar gnus-group-split-default-catch-all-group "mail.misc"
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
34 "Group name (or arbitrary fancy split) with default splitting rules.
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
35 Used by gnus-group-split and gnus-group-split-update as a fallback
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
36 split, in case none of the group-based splits matches.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;;###autoload
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 (defun gnus-group-split-setup (&optional auto-update catch-all)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 "Set up the split for nnmail-split-fancy.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 Sets things up so that nnmail-split-fancy is used for mail
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 splitting, and defines the variable nnmail-split-fancy according with
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 group parameters.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 If AUTO-UPDATE is non-nil (prefix argument accepted, if called
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 interactively), it makes sure nnmail-split-fancy is re-computed before
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 getting new mail, by adding gnus-group-split-update to
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
48 nnmail-pre-get-new-mail-hook.
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
49
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
50 A non-nil CATCH-ALL replaces the current value of
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
51 gnus-group-split-default-catch-all-group. This variable is only used
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
52 by gnus-group-split-update, and only when its CATCH-ALL argument is
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
53 nil. This argument may contain any fancy split, that will be added as
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
54 the last split in a `|' split produced by gnus-group-split-fancy,
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
55 unless overridden by any group marked as a catch-all group. Typical
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
56 uses are as simple as the name of a default mail group, but more
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
57 elaborate fancy splits may also be useful to split mail that doesn't
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
58 match any of the group-specified splitting rules. See
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
59 gnus-group-split-fancy for details."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (interactive "P")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 (setq nnmail-split-methods 'nnmail-split-fancy)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 (when catch-all
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 (setq gnus-group-split-default-catch-all-group catch-all))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (gnus-group-split-update)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 (when auto-update
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (add-hook 'nnmail-pre-get-new-mail-hook 'gnus-group-split-update)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;;;###autoload
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 (defun gnus-group-split-update (&optional catch-all)
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
70 "Computes nnmail-split-fancy from group params and CATCH-ALL, by
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
71 calling (gnus-group-split-fancy nil nil CATCH-ALL).
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
72
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
73 If CATCH-ALL is nil, gnus-group-split-default-catch-all-group is used
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
74 instead. This variable is set by gnus-group-split-setup."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (interactive)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (setq nnmail-split-fancy
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (gnus-group-split-fancy
33270
93c83ac38c92 2000-11-06 John Wiegley <johnw@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
78 nil (null nnmail-crosspost)
93c83ac38c92 2000-11-06 John Wiegley <johnw@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
79 (or catch-all gnus-group-split-default-catch-all-group)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (run-hooks 'gnus-group-split-updated-hook))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;;;###autoload
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 (defun gnus-group-split ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 "Uses information from group parameters in order to split mail.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 See gnus-group-split-fancy for more information.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 gnus-group-split is a valid value for nnmail-split-methods."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (let (nnmail-split-fancy)
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
89 (gnus-group-split-update)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (nnmail-split-fancy)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;;;###autoload
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (defun gnus-group-split-fancy
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (&optional groups no-crosspost catch-all)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 "Uses information from group parameters in order to split mail. It
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 can be embedded into nnmail-split-fancy lists with the SPLIT
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 \(: gnus-group-split-fancy GROUPS NO-CROSSPOST CATCH-ALL\)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 GROUPS may be a regular expression or a list of group names, that will
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 be used to select candidate groups. If it is ommited or nil, all
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 existing groups are considered.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 if NO-CROSSPOST is ommitted or nil, a & split will be returned,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 otherwise, a | split, that does not allow crossposting, will be
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 returned.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 For each selected group, a SPLIT is composed like this: if SPLIT-SPEC
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 is specified, this split is returned as-is (unless it is nil: in this
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 case, the group is ignored). Otherwise, if TO-ADDRESS, TO-LIST and/or
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 EXTRA-ALIASES are specified, a regexp that matches any of them is
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 constructed (extra-aliases may be a list). Additionally, if
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 SPLIT-REGEXP is specified, the regexp will be extended so that it
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 matches this regexp too, and if SPLIT-EXCLUDE is specified, RESTRICT
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 clauses will be generated.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116
33403
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
117 If CATCH-ALL is nil, no catch-all handling is performed, regardless of
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
118 catch-all marks in group parameters. Otherwise, if there is no
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
119 selected group whose SPLIT-REGEXP matches the empty string, nor is
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
120 there a selected group whose SPLIT-SPEC is 'catch-all, this fancy
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
121 split (say, a group name) will be appended to the returned SPLIT list,
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
122 as the last element of a '| SPLIT.
0ec780720bfe 2000-11-10 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Dave Love <fx@gnu.org>
parents: 33270
diff changeset
123
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 For example, given the following group parameters:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 nnml:mail.bar:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 \((to-address . \"bar@femail.com\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (split-regexp . \".*@femail\\\\.com\"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 nnml:mail.foo:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 \((to-list . \"foo@nowhere.gov\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (extra-aliases \"foo@localhost\" \"foo-redist@home\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (split-exclude \"bugs-foo\" \"rambling-foo\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (admin-address . \"foo-request@nowhere.gov\"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 nnml:mail.others:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 \((split-spec . catch-all))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 Calling (gnus-group-split-fancy nil nil \"mail.misc\") returns:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 \(| (& (any \"\\\\(bar@femail\\\\.com\\\\|.*@femail\\\\.com\\\\)\"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 \"mail.bar\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (any \"\\\\(foo@nowhere\\\\.gov\\\\|foo@localhost\\\\|foo-redist@home\\\\)\"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 - \"bugs-foo\" - \"rambling-foo\" \"mail.foo\"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 \"mail.others\")"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (let* ((newsrc (cdr gnus-newsrc-alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 split)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (dolist (info newsrc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (let ((group (gnus-info-group info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (params (gnus-info-params info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 ;; For all GROUPs that match the specified GROUPS
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (when (or (not groups)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (and (listp groups)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (memq group groups))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (and (stringp groups)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (string-match groups group)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (let ((split-spec (assoc 'split-spec params)) group-clean)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 ;; Remove backend from group name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (setq group-clean (string-match ":" group))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (setq group-clean
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (if group-clean
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (substring group (1+ group-clean))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 group))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (if split-spec
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (when (setq split-spec (cdr split-spec))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (if (eq split-spec 'catch-all)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 ;; Emit catch-all only when requested
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (when catch-all
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (setq catch-all group-clean))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ;; Append split-spec to the main split
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (push split-spec split)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 ;; Let's deduce split-spec from other params
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (let ((to-address (cdr (assoc 'to-address params)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (to-list (cdr (assoc 'to-list params)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (extra-aliases (cdr (assoc 'extra-aliases params)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (split-regexp (cdr (assoc 'split-regexp params)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (split-exclude (cdr (assoc 'split-exclude params))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (when (or to-address to-list extra-aliases split-regexp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ;; regexp-quote to-address, to-list and extra-aliases
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 ;; and add them all to split-regexp
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (setq split-regexp
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (concat
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 "\\("
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (mapconcat
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 'identity
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (append
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (and to-address (list (regexp-quote to-address)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (and to-list (list (regexp-quote to-list)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 (and extra-aliases
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (if (listp extra-aliases)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (mapcar 'regexp-quote extra-aliases)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (list extra-aliases)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (and split-regexp (list split-regexp)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 "\\|")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 "\\)"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 ;; Now create the new SPLIT
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (push (append
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (list 'any split-regexp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 ;; Generate RESTRICTs for SPLIT-EXCLUDEs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (if (listp split-exclude)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (let ((seq split-exclude)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 res)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (while seq
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (push (cons '- (pop seq))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 res))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (apply #'nconc (nreverse res)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (list '- split-exclude))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (list group-clean))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 split)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 ;; If it matches the empty string, it is a catch-all
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (when (string-match split-regexp "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (setq catch-all nil)))))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 ;; Add catch-all if not crossposting
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (if (and catch-all no-crosspost)
33270
93c83ac38c92 2000-11-06 John Wiegley <johnw@gnu.org>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
213 (push catch-all split))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 ;; Move it to the tail, while arranging that SPLITs appear in the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 ;; same order as groups.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (setq split (reverse split))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 ;; Decide whether to accept cross-postings or not.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (push (if no-crosspost '| '&) split)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 ;; Even if we can cross-post, catch-all should not get
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 ;; cross-posts.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (if (and catch-all (not no-crosspost))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (setq split (list '| split catch-all)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 split))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (provide 'gnus-mlspl)