(message-forward-make-body-mml): Remove headers according to
[gnus] / lisp / gnus-mlspl.el
1 ;;; gnus-mlspl.el --- a group params-based mail splitting mechanism
2
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004
4 ;;        Free Software Foundation, Inc.
5
6 ;; Author: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
7 ;; Keywords: news, mail
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published
13 ;; by the Free Software Foundation; either version 2, or (at your
14 ;; option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; see the file COPYING.  If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31 (require 'gnus)
32 (require 'gnus-sum)
33 (require 'gnus-group)
34 (require 'nnmail)
35
36 (defvar gnus-group-split-updated-hook nil
37   "Hook called just after `nnmail-split-fancy' is updated by
38 `gnus-group-split-update'.")
39
40 (defvar gnus-group-split-default-catch-all-group "mail.misc"
41   "Group name (or arbitrary fancy split) with default splitting rules.
42 Used by `gnus-group-split' and `gnus-group-split-update' as a fallback
43 split, in case none of the group-based splits matches.")
44
45 ;;;###autoload
46 (defun gnus-group-split-setup (&optional auto-update catch-all)
47   "Set up the split for `nnmail-split-fancy'.
48 Sets things up so that nnmail-split-fancy is used for mail
49 splitting, and defines the variable nnmail-split-fancy according with
50 group parameters.
51
52 If AUTO-UPDATE is non-nil (prefix argument accepted, if called
53 interactively), it makes sure nnmail-split-fancy is re-computed before
54 getting new mail, by adding `gnus-group-split-update' to
55 `nnmail-pre-get-new-mail-hook'.
56
57 A non-nil CATCH-ALL replaces the current value of
58 `gnus-group-split-default-catch-all-group'.  This variable is only used
59 by gnus-group-split-update, and only when its CATCH-ALL argument is
60 nil.  This argument may contain any fancy split, that will be added as
61 the last split in a `|' split produced by `gnus-group-split-fancy',
62 unless overridden by any group marked as a catch-all group.  Typical
63 uses are as simple as the name of a default mail group, but more
64 elaborate fancy splits may also be useful to split mail that doesn't
65 match any of the group-specified splitting rules.  See
66 `gnus-group-split-fancy' for details."
67   (interactive "P")
68   (setq nnmail-split-methods 'nnmail-split-fancy)
69   (when catch-all
70     (setq gnus-group-split-default-catch-all-group catch-all))
71   (gnus-group-split-update)
72   (when auto-update
73     (add-hook 'nnmail-pre-get-new-mail-hook 'gnus-group-split-update)))
74
75 ;;;###autoload
76 (defun gnus-group-split-update (&optional catch-all)
77   "Computes nnmail-split-fancy from group params and CATCH-ALL.
78 It does this by calling by calling (gnus-group-split-fancy nil
79 nil CATCH-ALL).
80
81 If CATCH-ALL is nil, `gnus-group-split-default-catch-all-group' is used
82 instead.  This variable is set by `gnus-group-split-setup'."
83   (interactive)
84   (setq nnmail-split-fancy
85         (gnus-group-split-fancy
86          nil (null nnmail-crosspost)
87          (or catch-all gnus-group-split-default-catch-all-group)))
88   (run-hooks 'gnus-group-split-updated-hook))
89