annotate lisp/gnus/nnmail.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 0293115a14e9
children 4103f0995bd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nnmail.el --- mail support functions for the Gnus mail backends
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news, mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'timezone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (require 'message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (eval-when-compile (require 'cl))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
32 (require 'custom)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
34 (defgroup gnus-mail nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
35 "Mailreading.."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
36 :group 'gnus)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
37
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
38 (defcustom nnmail-split-methods
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 '(("mail.misc" ""))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
40 "Incoming mail will be split according to this variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 If you'd like, for instance, one mail group for mail from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 \"4ad-l\" mailing list, one group for junk mail and one for everything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 else, you could do something like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq nnmail-split-methods
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 '((\"mail.4ad\" \"From:.*4ad\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (\"mail.junk\" \"From:.*Lars\\\\|Subject:.*buy\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (\"mail.misc\" \"\")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 As you can see, this variable is a list of lists, where the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 element in each \"rule\" is the name of the group (which, by the way,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 does not have to be called anything beginning with \"mail\",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 \"yonka.zow\" is a fine, fine name), and the second is a regexp that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 nnmail will try to match on the header to find a fit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 The second element can also be a function. In that case, it will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 called narrowed to the headers with the first element of the rule as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 the argument. It should return a non-nil value if it thinks that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 mail belongs in that group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 The last element should always have \"\" as the regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
64 This variable can also have a function as its value."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
65 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
66 :type '(choice (repeat :tag "Alist" (group (string :tag "Name") regexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
67 (function-item nnmail-split-fancy)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
68 (function :tag "Other")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; Suggested by Erik Selberg <speed@cs.washington.edu>.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
71 (defcustom nnmail-crosspost t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
72 "If non-nil, do crossposting if several split methods match the mail.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
73 If nil, the first match found will be used."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
74 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
75 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Added by gord@enci.ucalgary.ca (Gordon Matzigkeit).
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
78 (defcustom nnmail-keep-last-article nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
79 "If non-nil, nnmail will never delete the last expired article in a directory.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 You may need to set this variable if other programs are putting
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
81 new mail into folder numbers that Gnus has marked as expired."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
82 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
83 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
85 (defcustom nnmail-use-long-file-names nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
86 "If non-nil the mail backends will use long file and directory names.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 If nil, groups like \"mail.misc\" will end up in directories like
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
88 \"mail/misc/\"."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
89 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
90 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
92 (defcustom nnmail-default-file-modes 384
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
93 "Set the mode bits of all new mail files to this integer."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
94 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
95 :type 'integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
96
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
97 (defcustom nnmail-expiry-wait 7
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 "*Expirable articles that are older than this will be expired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 This variable can either be a number (which will be interpreted as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 number of days) -- this doesn't have to be an integer. This variable
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
101 can also be `immediate' and `never'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
102 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
103 :type '(choice (const immediate)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
104 (integer :tag "days")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
105 (const never)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
107 (defcustom nnmail-expiry-wait-function nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
108 "Variable that holds function to specify how old articles should be before they are expired.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 The function will be called with the name of the group that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 expiry is to be performed in, and it should return an integer that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 says how many days an article can be stored before it is considered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 \"old\". It can also return the values `never' and `immediate'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Eg.:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
116 \(setq nnmail-expiry-wait-function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (lambda (newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (cond ((string-match \"private\" newsgroup) 31)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ((string-match \"junk\" newsgroup) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ((string-match \"important\" newsgroup) 'never)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
121 (t 7))))"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
122 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
123 :type '(choice (const :tag "nnmail-expiry-wait" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
124 (function :format "%v" nnmail-)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
126 (defcustom nnmail-spool-file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (or (getenv "MAIL")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (concat "/usr/spool/mail/" (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "Where the mail backends will look for incoming mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 This variable is \"/usr/spool/mail/$user\" by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 If this variable is nil, no mail backends will read incoming mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 If this variable is a list, all files mentioned in this list will be
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
133 used as incoming mailboxes.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
134 If this variable is a directory (i. e., it's name ends with a \"/\"),
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
135 treat all files in that directory as incoming spool files."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
136 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
137 :type 'file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
139 (defcustom nnmail-crash-box "~/.gnus-crash-box"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
140 "File where Gnus will store mail while processing it."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
141 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
142 :type 'file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
144 (defcustom nnmail-use-procmail nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "*If non-nil, the mail backends will look in `nnmail-procmail-directory' for spool files.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
146 The file(s) in `nnmail-spool-file' will also be read."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
147 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
148 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
150 (defcustom nnmail-procmail-directory "~/incoming/"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "*When using procmail (and the like), incoming mail is put in this directory.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
152 The Gnus mail backends will read the mail from this directory."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
153 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
154 :type 'directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
156 (defcustom nnmail-procmail-suffix "\\.spool"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "*Suffix of files created by procmail (and the like).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 This variable might be a suffix-regexp to match the suffixes of
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
159 several files - eg. \".spool[0-9]*\"."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
160 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
161 :type 'regexp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
163 (defcustom nnmail-resplit-incoming nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
164 "*If non-nil, re-split incoming procmail sorted mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
165 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
166 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
168 (defcustom nnmail-delete-file-function 'delete-file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
169 "Function called to delete files in some mail backends."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
170 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
171 :type 'function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
172
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
173 (defcustom nnmail-crosspost-link-function 'add-name-to-file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Function called to create a copy of a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 This is `add-name-to-file' by default, which means that crossposts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 will use hard links. If your file system doesn't allow hard
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
177 links, you could set this variable to `copy-file' instead."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
178 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
179 :type '(radio (function-item add-name-to-file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
180 (function-item copy-file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
181 (function :tag "Other")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
183 (defcustom nnmail-movemail-program "movemail"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "*A command to be executed to move mail from the inbox.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
185 The default is \"movemail\".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
187 This can also be a function. In that case, the function will be
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
188 called with two parameters -- the name of the INBOX file, and the file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
189 to be moved to."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
190 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
191 :type 'string)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
193 (defcustom nnmail-pop-password-required nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
194 "*Non-nil if a password is required when reading mail using POP."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
195 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
196 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
197
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
198 (defcustom nnmail-read-incoming-hook
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
199 (if (eq system-type 'windows-nt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
200 '(nnheader-ms-strip-cr)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
201 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
202 "Hook that will be run after the incoming mail has been transferred.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 The incoming mail is moved from `nnmail-spool-file' (which normally is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 something like \"/usr/spool/mail/$user\") to the user's home
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
205 directory. This hook is called after the incoming mail box has been
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 emptied, and can be used to call any mail box programs you have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 running (\"xwatch\", etc.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 Eg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 \(add-hook 'nnmail-read-incoming-hook
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
212 (lambda ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (start-process \"mailsend\" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 \"/local/bin/mailsend\" \"read\" \"mbox\")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 If you have xwatch running, this will alert it that mail has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 If you use `display-time', you could use something like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 \(add-hook 'nnmail-read-incoming-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; Update the displayed time, since that will clear out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; the flag that says you have mail.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
225 (when (eq (process-status \"display-time\") 'run)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
226 (display-time-filter display-time-process \"\"))))"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
227 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
228 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Suggested by Erik Selberg <speed@cs.washington.edu>.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
231 (defcustom nnmail-prepare-incoming-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
232 "Hook called before treating incoming mail.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
233 The hook is run in a buffer with all the new, incoming mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
234 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
235 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
236
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
237 (defcustom nnmail-prepare-incoming-header-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
238 "Hook called narrowed to the headers of each message.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
239 This can be used to remove excessive spaces (and stuff like
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
240 that) from the headers before splitting and saving the messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
241 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
242 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
243
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
244 (defcustom nnmail-prepare-incoming-message-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
245 "Hook called narrowed to each message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
246 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
247 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
249 (defcustom nnmail-list-identifiers nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
250 "Regexp that matches list identifiers to be removed.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
251 This can also be a list of regexps."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
252 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
253 :type '(choice regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
254 (repeat regexp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
255
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
256 (defcustom nnmail-pre-get-new-mail-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
257 "Hook called just before starting to handle new incoming mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
258 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
259 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
261 (defcustom nnmail-post-get-new-mail-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
262 "Hook called just after finishing handling new incoming mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
263 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
264 :type 'hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
265
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
266 (defcustom nnmail-split-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
267 "Hook called before deciding where to split an article.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
268 The functions in this hook are free to modify the buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
269 contents in any way they choose -- the buffer contents are
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
270 discarded after running the split process."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
271 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
272 :type 'hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; Suggested by Mejia Pablo J <pjm9806@usl.edu>.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
275 (defcustom nnmail-tmp-directory nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
276 "*If non-nil, use this directory for temporary storage when reading incoming mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
277 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
278 :type '(choice (const :tag "default" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
279 (directory :format "%v")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
281 (defcustom nnmail-large-newsgroup 50
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "*The number of the articles which indicates a large newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 If the number of the articles is greater than the value, verbose
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
284 messages will be shown to indicate the current status."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
285 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
286 :type 'integer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
288 (defcustom nnmail-split-fancy "mail.misc"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
289 "Incoming mail can be split according to this fancy variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 To enable this, set `nnmail-split-methods' to `nnmail-split-fancy'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 The format is this variable is SPLIT, where SPLIT can be one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
295 GROUP: Mail will be stored in GROUP (a string).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 \(FIELD VALUE SPLIT): If the message field FIELD (a regexp) contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 VALUE (a regexp), store the messages as specified by SPLIT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 \(| SPLIT...): Process each SPLIT expression until one of them matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 A SPLIT expression is said to match if it will cause the mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 message to be stored in one or more groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 \(& SPLIT...): Process each SPLIT expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
306 \(: FUNCTION optional args): Call FUNCTION with the optional args, in
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
307 the buffer containing the message headers. The return value FUNCTION
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
308 should be a split, which is then recursively processed.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
309
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 FIELD must match a complete field name. VALUE must match a complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 word according to the `nnmail-split-fancy-syntax-table' syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 You can use .* in the regexps to match partial field names or words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 FIELD and VALUE can also be lisp symbols, in that case they are expanded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 as specified in `nnmail-split-abbrev-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
317 GROUP can contain \\& and \\N which will substitute from matching
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
318 \\(\\) patterns in the previous VALUE.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
319
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 Example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 \(setq nnmail-split-methods 'nnmail-split-fancy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 nnmail-split-fancy
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
324 ;; Messages from the mailer daemon are not crossposted to any of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; the ordinary groups. Warnings are put in a separate group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; from real errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 \"mail.misc\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; Non-error messages are crossposted to all relevant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; groups, but we don't crosspost between the group for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; (ding) list and the group for other (ding) related mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (& (| (any \"ding@ifi\\\\.uio\\\\.no\" \"ding.list\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (\"subject\" \"ding\" \"ding.misc\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Other mailing lists...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (any \"procmail@informatik\\\\.rwth-aachen\\\\.de\" \"procmail.list\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (any \"SmartList@informatik\\\\.rwth-aachen\\\\.de\" \"SmartList.list\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; People...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (any \"larsi@ifi\\\\.uio\\\\.no\" \"people.Lars Magne Ingebrigtsen\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; Unmatched mail goes to the catch all group.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
340 \"misc.misc\"))"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
341 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
342 ;; Sigh!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
343 :type 'sexp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
345 (defcustom nnmail-split-abbrev-alist
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
346 '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
347 (mail . "mailer-daemon\\|postmaster\\|uucp"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
348 "Alist of abbreviations allowed in `nnmail-split-fancy'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
349 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
350 :type '(repeat (cons :format "%v" symbol regexp)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
352 (defcustom nnmail-delete-incoming t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
353 "*If non-nil, the mail backends will delete incoming files after
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
354 splitting."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
355 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
356 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
358 (defcustom nnmail-message-id-cache-length 1000
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "*The approximate number of Message-IDs nnmail will keep in its cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 If this variable is nil, no checking on duplicate messages will be
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
361 performed."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
362 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
363 :type '(choice (const :tag "disable" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
364 (integer :format "%v")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
366 (defcustom nnmail-message-id-cache-file "~/.nnmail-cache"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
367 "*The file name of the nnmail Message-ID cache."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
368 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
369 :type 'file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
371 (defcustom nnmail-treat-duplicates 'warn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "*If non-nil, nnmail keep a cache of Message-IDs to discover mail duplicates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 Three values are legal: nil, which means that nnmail is not to keep a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Message-ID cache; `warn', which means that nnmail should insert extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 headers to warn the user about the duplication (this is the default);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 and `delete', which means that nnmail will delete duplicated mails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 This variable can also be a function. It will be called from a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 narrowed to the article in question with the Message-ID as a
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
380 parameter. It should return nil, `warn' or `delete'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
381 :group 'gnus-mail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
382 :type '(choice (const :tag "off" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
383 (const warn)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
384 (const delete)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
388 (defvar nnmail-split-history nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
389 "List of group/article elements that say where the previous split put messages.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
390
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defvar nnmail-pop-password nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "*Password to use when reading mail from a POP server, if required.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
394 (defvar nnmail-split-fancy-syntax-table nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Syntax table used by `nnmail-split-fancy'.")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
396 (unless (syntax-table-p nnmail-split-fancy-syntax-table)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
397 (setq nnmail-split-fancy-syntax-table
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
398 (copy-syntax-table (standard-syntax-table)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
399 ;; support the %-hack
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
400 (modify-syntax-entry ?\% "." nnmail-split-fancy-syntax-table))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defvar nnmail-prepare-save-mail-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "Hook called before saving mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defvar nnmail-moved-inboxes nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "List of inboxes that have been moved.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defvar nnmail-internal-password nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (defconst nnmail-version "nnmail 1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 "nnmail version.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defun nnmail-request-post (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (mail-send-and-exit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun nnmail-find-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "Insert FILE in server buffer safely."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (let ((format-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (after-insert-file-functions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (progn (insert-file-contents file) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (file-error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defun nnmail-group-pathname (group dir &optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "Make pathname for GROUP."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((dir (file-name-as-directory (expand-file-name dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; If this directory exists, we use it directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (or nnmail-use-long-file-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (file-directory-p (concat dir group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (concat dir group "/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; If not, we translate dots into slashes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (concat dir (nnheader-replace-chars-in-string group ?. ?/) "/")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (or file "")))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
441
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun nnmail-date-to-time (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 "Convert DATE into time."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
444 (condition-case ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
445 (let* ((d1 (timezone-parse-date date))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
446 (t1 (timezone-parse-time (aref d1 3))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
447 (apply 'encode-time
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
448 (mapcar (lambda (el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
449 (and el (string-to-number el)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
450 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
451 (aref t1 2) (aref t1 1) (aref t1 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
452 (aref d1 2) (aref d1 1) (aref d1 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
453 (number-to-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
454 (* 60 (timezone-zone-to-minute (aref d1 4))))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
455 ;; If we get an error, then we just return a 0 time.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
456 (error (list 0 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun nnmail-time-less (t1 t2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "Say whether time T1 is less than time T2."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (or (< (car t1) (car t2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (and (= (car t1) (car t2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (< (nth 1 t1) (nth 1 t2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defun nnmail-days-to-time (days)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 "Convert DAYS into time."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (let* ((seconds (* 1.0 days 60 60 24))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (rest (expt 2 16))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
468 (ms (condition-case nil (round (/ seconds rest))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (range-error (expt 2 16)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (list ms (condition-case nil (round (- seconds (* ms rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (range-error (expt 2 16))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defun nnmail-time-since (time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "Return the time since TIME, which is either an internal time or a date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (when (stringp time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; Convert date strings to internal time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq time (nnmail-date-to-time time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let* ((current (current-time))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
479 (rest (when (< (nth 1 current) (nth 1 time))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
480 (expt 2 16))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (list (- (+ (car current) (if rest -1 0)) (car time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (- (+ (or rest 0) (nth 1 current)) (nth 1 time)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; Function rewritten from rmail.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (defun nnmail-move-inbox (inbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 "Move INBOX to `nnmail-crash-box'."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
487 (if (not (file-writable-p nnmail-crash-box))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
488 (gnus-error 1 "Can't write to crash box %s. Not moving mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
489 nnmail-crash-box)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
490 ;; If the crash box exists and is empty, we delete it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
491 (when (and (file-exists-p nnmail-crash-box)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
492 (zerop (nnheader-file-size (file-truename nnmail-crash-box))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
493 (delete-file nnmail-crash-box))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
494 (let ((inbox (file-truename (expand-file-name inbox)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
495 (tofile (file-truename (expand-file-name nnmail-crash-box)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
496 movemail popmail errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
497 (if (setq popmail (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
498 "^po:" (file-name-nondirectory inbox)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
499 (setq inbox (file-name-nondirectory inbox))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
500 (setq movemail t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
501 ;; On some systems, /usr/spool/mail/foo is a directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
502 ;; and the actual inbox is /usr/spool/mail/foo/foo.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
503 (when (file-directory-p inbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
504 (setq inbox (expand-file-name (user-login-name) inbox))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
505 (if (member inbox nnmail-moved-inboxes)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
506 ;; We don't try to move an already moved inbox.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
507 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
508 (if popmail
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
509 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
510 (when (and nnmail-pop-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
511 (not nnmail-internal-password))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
512 (setq nnmail-internal-password nnmail-pop-password))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
513 (when (and nnmail-pop-password-required
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
514 (not nnmail-internal-password))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
515 (setq nnmail-internal-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
516 (nnmail-read-passwd
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
517 (format "Password for %s: "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
518 (substring inbox (+ popmail 3))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
519 (message "Getting mail from post office ..."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
520 (when (or (and (file-exists-p tofile)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
521 (/= 0 (nnheader-file-size tofile)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
522 (and (file-exists-p inbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
523 (/= 0 (nnheader-file-size inbox))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
524 (message "Getting mail from %s..." inbox)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
525 ;; Set TOFILE if have not already done so, and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
526 ;; rename or copy the file INBOX to TOFILE if and as appropriate.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
527 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
528 ((file-exists-p tofile)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
529 ;; The crash box exists already.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
530 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
531 ((and (not popmail)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
532 (not (file-exists-p inbox)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
533 ;; There is no inbox.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
534 (setq tofile nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
535 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
536 ;; If getting from mail spool directory, use movemail to move
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
537 ;; rather than just renaming, so as to interlock with the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
538 ;; mailer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
539 (unwind-protect
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
540 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
541 (setq errors (generate-new-buffer " *nnmail loss*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
542 (buffer-disable-undo errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
543 (let ((default-directory "/"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
544 (if (nnheader-functionp nnmail-movemail-program)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
545 (funcall nnmail-movemail-program inbox tofile)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
546 (apply
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
547 'call-process
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
548 (append
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
549 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
550 (expand-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
551 nnmail-movemail-program exec-directory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
552 nil errors nil inbox tofile)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
553 (when nnmail-internal-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
554 (list nnmail-internal-password))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
555 (if (not (buffer-modified-p errors))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
556 ;; No output => movemail won
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
557 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
558 (unless popmail
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
559 (when (file-exists-p tofile)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
560 (set-file-modes tofile nnmail-default-file-modes)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
561 (push inbox nnmail-moved-inboxes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
562 (set-buffer errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
563 ;; There may be a warning about older revisions. We
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
564 ;; ignore those.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
565 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
566 (if (search-forward "older revision" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
567 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
568 (unless popmail
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
569 (when (file-exists-p tofile)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
570 (set-file-modes tofile nnmail-default-file-modes)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
571 (push inbox nnmail-moved-inboxes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
572 ;; Probably a real error.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
573 (subst-char-in-region (point-min) (point-max) ?\n ?\ )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
574 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
575 (skip-chars-backward " \t")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
576 (delete-region (point) (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
577 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
578 (when (looking-at "movemail: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
579 (delete-region (point-min) (match-end 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
580 (unless (yes-or-no-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
581 (format "movemail: %s. Continue? "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
582 (buffer-string)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
583 (error "%s" (buffer-string)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
584 (setq tofile nil)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
585 (message "Getting mail from %s...done" inbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
586 (and errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
587 (buffer-name errors)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
588 (kill-buffer errors))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
589 tofile))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun nnmail-get-active ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Returns an assoc of group names and active ranges.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 nn*-request-list should have been called before calling this function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (let (group-assoc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; Go through all groups from the active list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "^\\([^ \t]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; We create an alist with `(GROUP (LOW . HIGH))' elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (push (list (match-string 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (cons (string-to-int (match-string 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (string-to-int (match-string 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 group-assoc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 group-assoc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (defun nnmail-save-active (group-assoc file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 "Save GROUP-ASSOC in ACTIVE-FILE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (when file-name
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
611 (nnheader-temp-write file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
612 (nnmail-generate-active group-assoc))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
613
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
614 (defun nnmail-generate-active (alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
615 "Generate an active file from group-alist ALIST."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
616 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
617 (let (group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
618 (while (setq group (pop alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
619 (insert (format "%s %d %d y\n" (car group) (cdadr group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
620 (caadr group))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (defun nnmail-get-split-group (file group)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
623 "Find out whether this FILE is to be split into GROUP only.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
624 If GROUP is non-nil and we are using procmail, return the group name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
625 only when the file is the correct procmail file. When GROUP is nil,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
626 return nil if FILE is a spool file or the procmail group for which it
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
627 is a spool. If not using procmail, return GROUP."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (if (or (eq nnmail-spool-file 'procmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 nnmail-use-procmail)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
630 (if (string-match (concat "^" (expand-file-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
631 (file-name-as-directory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
632 nnmail-procmail-directory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
633 "\\([^/]*\\)" nnmail-procmail-suffix "$")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
634 (expand-file-name file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
635 (let ((procmail-group (substring (expand-file-name file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
636 (match-beginning 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
637 (match-end 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
638 (if group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
639 (if (string-equal group procmail-group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
640 group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
641 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
642 procmail-group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
643 nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
646 (defun nnmail-process-babyl-mail-format (func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 start message-id content-length do-search end)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
649 (goto-char (point-min))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 " \n0, *unseen,+\n\\(\\*\\*\\* EOOH \\*\\*\\*\n\\)?" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (delete-region (match-beginning 0) (match-end 0))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
655 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
656 (setq start (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
657 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
658 ;; Skip all the headers in case there are more "From "s...
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
659 (or (search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
660 (search-forward-regexp "^[^:]*\\( .*\\|\\)$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
661 (search-forward " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
662 (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
663 ;; Unquote the ">From " line, if any.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
664 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
665 (when (looking-at ">From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
666 (replace-match "X-From-Line: ") )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
667 (run-hooks 'nnmail-prepare-incoming-header-hook)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
668 (goto-char (point-max))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; Find the Message-ID header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (if (re-search-backward "^Message-ID:[ \t]*\\(<[^>]*>\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (setq message-id (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; There is no Message-ID here, so we create one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (when (re-search-backward "^Message-ID:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (insert "Original-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (insert "Message-ID: " (setq message-id (nnmail-message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;; Look for a Content-Length header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (if (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (and (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 "^Content-Length:[ \t]*\\([0-9]+\\)" start t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (setq content-length (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; We destroy the header, since none of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ;; the backends ever use it, and we do not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; want to confuse other mailers by having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; a (possibly) faulty header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (progn (insert "X-") t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (setq do-search t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
696 (widen)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (if (or (= (+ (point) content-length) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (goto-char (+ (point) content-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (looking-at "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (goto-char (+ (point) content-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (setq do-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (setq do-search t)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
705 (widen)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; Go to the beginning of the next article - or to the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; of the buffer.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
708 (when do-search
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
709 (if (re-search-forward "^" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
710 (goto-char (match-beginning 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
711 (goto-char (1- (point-max)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (delete-char 1) ; delete ^_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (narrow-to-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
717 (nnmail-check-duplication message-id func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (goto-char end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (defun nnmail-search-unix-mail-delim ()
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
722 "Put point at the beginning of the next Unix mbox message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
723 ;; Algorithm used to find the the next article in the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
724 ;; brain-dead Unix mbox format:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
725 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
726 ;; 1) Search for "^From ".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
727 ;; 2) If we find it, then see whether the previous
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
728 ;; line is blank and the next line looks like a header.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
729 ;; Then it's possible that this is a mail delim, and we use it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
730 (let ((case-fold-search nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (while (not found)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
733 (if (not (re-search-forward "^From " nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
734 (setq found 'no)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
735 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
736 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
737 (when (and (or (bobp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
738 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
739 (forward-line -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
740 (= (following-char) ?\n)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
741 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
742 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
743 (while (looking-at ">From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
744 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
745 (looking-at "[^ \t:]+[ \t]*:")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
746 (setq found 'yes)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
747 (beginning-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (eq found 'yes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
750 (defun nnmail-search-unix-mail-delim-backward ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
751 "Put point at the beginning of the current Unix mbox message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
752 ;; Algorithm used to find the the next article in the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
753 ;; brain-dead Unix mbox format:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
754 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
755 ;; 1) Search for "^From ".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
756 ;; 2) If we find it, then see whether the previous
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
757 ;; line is blank and the next line looks like a header.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
758 ;; Then it's possible that this is a mail delim, and we use it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
759 (let ((case-fold-search nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
760 found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
761 (while (not found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
762 (if (not (re-search-backward "^From " nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
763 (setq found 'no)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
764 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
765 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
766 (when (and (or (bobp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
767 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
768 (forward-line -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
769 (= (following-char) ?\n)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
770 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
771 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
772 (while (looking-at ">From ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
773 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
774 (looking-at "[^ \t:]+[ \t]*:")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
775 (setq found 'yes)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
776 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
777 (eq found 'yes)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
778
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
779 (defun nnmail-process-unix-mail-format (func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 start message-id content-length end skip head-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
783 (if (not (and (re-search-forward "^From " nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; Possibly wrong format?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (error "Error, unknown mail format! (Possibly corrupted.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; Carry on until the bitter end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (setq start (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; Find the end of the head.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; This will never happen, but just to be on the safe side --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 ;; if there is no head-body delimiter, we search a bit manually.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (while (and (looking-at "From \\|[^ \t]+:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; Find the Message-ID header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq message-id (match-string 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (when (re-search-forward "^Message-ID:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (insert "Original-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;; There is no Message-ID here, so we create one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ;; Look for a Content-Length header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (if (not (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 "^Content-Length:[ \t]*\\([0-9]+\\)" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (setq content-length nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (setq content-length (string-to-int (match-string 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; We destroy the header, since none of the backends ever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; use it, and we do not want to confuse other mailers by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;; having a (possibly) faulty header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (insert "X-"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
824 (run-hooks 'nnmail-prepare-incoming-header-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; Find the end of this article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (setq head-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; We try the Content-Length value. The idea: skip over the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; separator, then check what happens content-length bytes into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; message body. This should be either the end ot the buffer, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; message separator or a blank line followed by the separator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; The blank line should probably be deleted. If neither of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; three is met, the content-length header is probably invalid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (when content-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq skip (+ (point) content-length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (goto-char skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (cond ((or (= skip (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (= (1+ skip) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (setq end (point-max)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
842 ((looking-at "From ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (setq end skip))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
844 ((looking-at "[ \t]*\n\\(From \\)")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setq end (match-beginning 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (t (setq end nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; No Content-Length, so we find the beginning of the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;; article or the end of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (goto-char head-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (or (nnmail-search-unix-mail-delim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;; Allow the backend to save the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (narrow-to-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
859 (nnmail-check-duplication message-id func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (setq end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (goto-char end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
863 (defun nnmail-process-mmdf-mail-format (func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (let ((delim "^\^A\^A\^A\^A$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 start message-id end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (if (not (and (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;; Possibly wrong format?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (error "Error, unknown mail format! (Possibly corrupted.)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; Carry on until the bitter end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;; Find the end of the head.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (narrow-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (if (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; This will never happen, but just to be on the safe side --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; if there is no head-body delimiter, we search a bit manually.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (while (and (looking-at "From \\|[^ \t]+:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 ;; Find the Message-ID header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (setq message-id (match-string 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; There is no Message-ID here, so we create one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (when (re-search-backward "^Message-ID:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (insert "Original-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
897 (run-hooks 'nnmail-prepare-incoming-header-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 ;; Find the end of this article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (if (re-search-forward delim nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ;; Allow the backend to save the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (narrow-to-region start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
909 (nnmail-check-duplication message-id func artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq end (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (forward-line 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
914 (defun nnmail-split-incoming (incoming func &optional exit-func
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
915 group artnum-func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 "Go through the entire INCOMING file and pick out each individual mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 FUNC will be called with the buffer narrowed to each mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (let (;; If this is a group-specific split, we bind the split
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ;; methods to just this group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (nnmail-split-methods (if (and group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (or (eq nnmail-spool-file 'procmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 nnmail-use-procmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (not nnmail-resplit-incoming))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (list (list group ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 nnmail-split-methods)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; Insert the incoming file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (set-buffer (get-buffer-create " *nnmail incoming*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (erase-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
931 (nnheader-insert-file-contents incoming)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (unless (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; Handle both babyl, MMDF and unix mail formats, since movemail will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;; use the former when fetching from a mailbox, the latter when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;; fetches from a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (cond ((or (looking-at "\^L")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (looking-at "BABYL OPTIONS:"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
940 (nnmail-process-babyl-mail-format func artnum-func))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ((looking-at "\^A\^A\^A\^A")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
942 (nnmail-process-mmdf-mail-format func artnum-func))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
944 (nnmail-process-unix-mail-format func artnum-func))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
945 (when exit-func
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
946 (funcall exit-func))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; Mail crossposts suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (defun nnmail-article-group (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 "Look at the headers and return an alist of groups that match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 FUNC will be called with the group name to determine the article number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (let ((methods nnmail-split-methods)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (obuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (beg (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 end group-art method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (if (and (sequencep methods) (= (length methods) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;; If there is only just one group to put everything in, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ;; just return a list with just this one method in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (setq group-art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (list (cons (caar methods) (funcall func (caar methods)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;; We do actual comparison.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 ;; Find headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (setq end (if (search-forward "\n\n" nil t) (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (set-buffer nntp-server-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; Copy the headers into the work buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (insert-buffer-substring obuf beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; Fold continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (replace-match " " t t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
975 ;; Allow washing.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
976 (run-hooks 'nnmail-split-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (if (and (symbolp nnmail-split-methods)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (fboundp nnmail-split-methods))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
979 (let ((split
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (or (funcall nnmail-split-methods)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 '("bogus"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "Error in `nnmail-split-methods'; using `bogus' mail group")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 '("bogus")))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
988 (unless (equal split '(junk))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
989 ;; `nnmail-split-methods' is a function, so we just call
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
990 ;; this function here and use the result.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
991 (setq group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
992 (mapcar
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
993 (lambda (group) (cons group (funcall func group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
994 split))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; Go through the split methods to find a match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (while (and methods (or nnmail-crosspost (not group-art)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (setq method (pop methods))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (if (or methods
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (not (equal "" (nth 1 method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (when (and
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1002 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1003 (if (stringp (nth 1 method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1004 (re-search-backward (cadr method) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1005 ;; Function to say whether this is a match.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1006 (funcall (nth 1 method) (car method))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ;; Don't enter the article into the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ;; group twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (not (assoc (car method) group-art)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1010 (push (cons (car method) (funcall func (car method)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 group-art))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; This is the final group, which is used as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;; catch-all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (unless group-art
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (setq group-art
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1016 (list (cons (car method)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (funcall func (car method)))))))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1018 ;; See whether the split methods returned `junk'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1019 (if (equal group-art '(junk))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1020 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1021 (nreverse (delq 'junk group-art)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (defun nnmail-insert-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 "Insert how many lines there are in the body of the mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 Return the number of characters in the body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (let (lines chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1029 (when (search-forward "\n\n" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (setq chars (- (point-max) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (setq lines (count-lines (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (when (re-search-backward "^Lines: " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (delete-region (point) (progn (forward-line 1) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (insert (format "Lines: %d\n" (max lines 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 chars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (defun nnmail-insert-xref (group-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 "Insert an Xref line based on the (group . article) alist."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1044 (when (search-forward "\n\n" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (when (re-search-backward "^Xref: " nil t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1047 (delete-region (match-beginning 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (progn (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (insert (format "Xref: %s" (system-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (while group-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (insert (format " %s:%d" (caar group-alist) (cdar group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (setq group-alist (cdr group-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1055 ;;; Message washing functions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1056
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1057 (defun nnmail-remove-leading-whitespace ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1058 "Remove excessive whitespace from all headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1059 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1060 (while (re-search-forward "^\\([^ :]+: \\) +" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1061 (replace-match "\\1" t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1062
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1063 (defun nnmail-remove-list-identifiers ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1064 "Remove list identifiers from Subject headers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1065 (let ((regexp (if (stringp nnmail-list-identifiers) nnmail-list-identifiers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1066 (mapconcat 'identity nnmail-list-identifiers "\\|"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1067 (when regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1068 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1069 (when (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1070 (concat "^Subject: +\\(Re: +\\)?\\(" regexp "\\) *")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1071 nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1072 (delete-region (match-beginning 2) (match-end 0))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1073
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1074 (defun nnmail-remove-tabs ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1075 "Translate TAB characters into SPACE characters."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1076 (subst-char-in-region (point-min) (point-max) ?\t ? t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1077
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1078 ;;; Utility functions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1079
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ;; Written by byer@mv.us.adobe.com (Scott Byer).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (defun nnmail-make-complex-temp-name (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (let ((newname (make-temp-name prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (newprefix prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (while (file-exists-p newname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (setq newprefix (concat newprefix "x"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (setq newname (make-temp-name newprefix)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (defun nnmail-split-fancy ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 "Fancy splitting method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 See the documentation for the variable `nnmail-split-fancy' for documentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (let ((syntab (syntax-table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (set-syntax-table nnmail-split-fancy-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (nnmail-split-it nnmail-split-fancy))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (set-syntax-table syntab))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (defvar nnmail-split-cache nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 ;; Alist of split expressions their equivalent regexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (defun nnmail-split-it (split)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 ;; Return a list of groups matching SPLIT.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1106 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1107 ;; nil split
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1108 ((null split)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1109 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1110
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1111 ;; A group name. Do the \& and \N subs into the string.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1112 ((stringp split)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1113 (list (nnmail-expand-newtext split)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1114
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1115 ;; Junk the message.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1116 ((eq split 'junk)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1117 (list 'junk))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1118
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1119 ;; Builtin & operation.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1120 ((eq (car split) '&)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1121 (apply 'nconc (mapcar 'nnmail-split-it (cdr split))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1122
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1123 ;; Builtin | operation.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1124 ((eq (car split) '|)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1125 (let (done)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1126 (while (and (not done) (cdr split))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1127 (setq split (cdr split)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1128 done (nnmail-split-it (car split))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1129 done))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1130
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1131 ;; Builtin : operation.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1132 ((eq (car split) ':)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1133 (nnmail-split-it (eval (cdr split))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1134
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1135 ;; Check the cache for the regexp for this split.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1136 ;; FIX FIX FIX could avoid calling assq twice here
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1137 ((assq split nnmail-split-cache)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1138 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1139 ;; FIX FIX FIX problem with re-search-backward is that if you have
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1140 ;; a split: (from "foo-\\(bar\\|baz\\)@gnus.org "mail.foo.\\1")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1141 ;; and someone mails a message with 'To: foo-bar@gnus.org' and
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1142 ;; 'CC: foo-baz@gnus.org', we'll pick 'mail.foo.baz' as the group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1143 ;; if the cc line is a later header, even though the other choice
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1144 ;; is probably better. Also, this routine won't do a crosspost
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1145 ;; when there are two different matches.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1146 ;; I guess you could just make this more determined, and it could
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1147 ;; look for still more matches prior to this one, and recurse
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1148 ;; on each of the multiple matches hit. Of course, then you'd
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1149 ;; want to make sure that nnmail-article-group or nnmail-split-fancy
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1150 ;; removed duplicates, since there might be more of those.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1151 ;; I guess we could also remove duplicates in the & split case, since
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1152 ;; that's the only thing that can introduce them.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1153 (when (re-search-backward (cdr (assq split nnmail-split-cache)) nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1154 ;; Someone might want to do a \N sub on this match, so get the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1155 ;; correct match positions.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1156 (goto-char (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1157 (let ((value (nth 1 split)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1158 (re-search-backward (if (symbolp value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1159 (cdr (assq value nnmail-split-abbrev-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1160 value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1161 (match-end 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1162 (nnmail-split-it (nth 2 split))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1163
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1164 ;; Not in cache, compute a regexp for the field/value pair.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1165 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1166 (let* ((field (nth 0 split))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1167 (value (nth 1 split))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1168 (regexp (concat "^\\(\\("
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1169 (if (symbolp field)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1170 (cdr (assq field nnmail-split-abbrev-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1171 field)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1172 "\\):.*\\)\\<\\("
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1173 (if (symbolp value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1174 (cdr (assq value nnmail-split-abbrev-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1175 value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1176 "\\)\\>")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1177 (push (cons split regexp) nnmail-split-cache)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1178 ;; Now that it's in the cache, just call nnmail-split-it again
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1179 ;; on the same split, which will find it immediately in the cache.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1180 (nnmail-split-it split)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1181
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1182 (defun nnmail-expand-newtext (newtext)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1183 (let ((len (length newtext))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1184 (pos 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1185 c expanded beg N did-expand)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1186 (while (< pos len)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1187 (setq beg pos)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1188 (while (and (< pos len)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1189 (not (= (aref newtext pos) ?\\)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1190 (setq pos (1+ pos)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1191 (unless (= beg pos)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1192 (push (substring newtext beg pos) expanded))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1193 (when (< pos len)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1194 ;; we hit a \, expand it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1195 (setq did-expand t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1196 (setq pos (1+ pos))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1197 (setq c (aref newtext pos))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1198 (if (not (or (= c ?\&)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1199 (and (>= c ?1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1200 (<= c ?9))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1201 ;; \ followed by some character we don't expand
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1202 (push (char-to-string c) expanded)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1203 ;; \& or \N
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1204 (if (= c ?\&)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1205 (setq N 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1206 (setq N (- c ?0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1207 (when (match-beginning N)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1208 (push (buffer-substring (match-beginning N) (match-end N))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1209 expanded))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1210 (setq pos (1+ pos)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1211 (if did-expand
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1212 (apply 'concat (nreverse expanded))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1213 newtext)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; Get a list of spool files to read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (defun nnmail-get-spool-files (&optional group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (if (null nnmail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; No spool file whatsoever.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (let* ((procmails
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; If procmail is used to get incoming mail, the files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; are stored in this directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (and (file-exists-p nnmail-procmail-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (or (eq nnmail-spool-file 'procmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 nnmail-use-procmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (directory-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 nnmail-procmail-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 t (concat (if group (concat "^" group) "")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1229 nnmail-procmail-suffix "$"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (p procmails)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (crash (when (and (file-exists-p nnmail-crash-box)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1232 (> (nnheader-file-size
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1233 (file-truename nnmail-crash-box))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1234 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (list nnmail-crash-box))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1236 ;; Remove any directories that inadvertently match the procmail
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 ;; suffix, which might happen if the suffix is "".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (when (file-directory-p (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (setq procmails (delete (car p) procmails)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; Return the list of spools.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 crash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (cond ((and group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (or (eq nnmail-spool-file 'procmail)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1247 nnmail-use-procmail)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1248 procmails)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 procmails)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1250 ((and group
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1251 (eq nnmail-spool-file 'procmail))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1252 nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ((listp nnmail-spool-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1254 (nconc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1255 (apply
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1256 'nconc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1257 (mapcar
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1258 (lambda (file)
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1259 (if (and (not (string-match "^po:" file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1260 (file-directory-p file))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1261 (nnheader-directory-regular-files file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1262 (list file)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1263 nnmail-spool-file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1264 procmails))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1265 ((stringp nnmail-spool-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1266 (if (and (not (string-match "^po:" nnmail-spool-file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1267 (file-directory-p nnmail-spool-file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1268 (nconc
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1269 (nnheader-directory-regular-files nnmail-spool-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1270 procmails)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
1271 (cons nnmail-spool-file procmails)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ((eq nnmail-spool-file 'pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (cons (format "po:%s" (user-login-name)) procmails))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 procmails))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ;; Activate a backend only if it isn't already activated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 ;; If FORCE, re-read the active file even if the backend is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;; already activated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (defun nnmail-activate (backend &optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (let (file timestamp file-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (if (or (not (symbol-value (intern (format "%s-group-alist" backend))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 force
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1284 (and (setq file (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1285 (symbol-value (intern (format "%s-active-file"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1286 backend)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (setq file-time (nth 5 (file-attributes file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (or (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (setq timestamp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (symbol-value (intern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (format "%s-active-timestamp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 backend)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (error 'none))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (not (consp timestamp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (equal timestamp '(0 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (> (nth 0 file-time) (nth 0 timestamp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (and (= (nth 0 file-time) (nth 0 timestamp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (> (nth 1 file-time) (nth 1 timestamp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (or (eq timestamp 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (set (intern (format "%s-active-timestamp" backend))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1303 ;;; dmoore@ucsd.edu 25.10.96
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1304 ;;; it's not always the case that current-time
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1305 ;;; does correspond to changes in the file's time. So just compare
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1306 ;;; the file's new time against its own previous time.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1307 ;;; (current-time)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1308 file-time
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1309 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (funcall (intern (format "%s-request-list" backend)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1311 ;;; dmoore@ucsd.edu 25.10.96
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1312 ;;; BACKEND-request-list already does this itself!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1313 ;;; (set (intern (format "%s-group-alist" backend))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1314 ;;; (nnmail-get-active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1315 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (defun nnmail-message-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (concat "<" (message-unique-id) "@totally-fudged-out-message-id>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ;;; nnmail duplicate handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (defvar nnmail-cache-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (defun nnmail-cache-open ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (if (or (not nnmail-treat-duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (and nnmail-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (buffer-name nnmail-cache-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 () ; The buffer is open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (setq nnmail-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (get-buffer-create " *nnmail message-id cache*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (buffer-disable-undo (current-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1337 (when (file-exists-p nnmail-message-id-cache-file)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1338 (nnheader-insert-file-contents nnmail-message-id-cache-file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (defun nnmail-cache-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (when (and nnmail-cache-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 nnmail-treat-duplicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (buffer-name nnmail-cache-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (buffer-modified-p nnmail-cache-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (set-buffer nnmail-cache-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 ;; Weed out the excess number of Message-IDs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (goto-char (point-max))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1351 (when (search-backward "\n" nil t nnmail-message-id-cache-length)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1352 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1353 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1354 (delete-region (point-min) (point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 ;; Save the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (or (file-exists-p (file-name-directory nnmail-message-id-cache-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (make-directory (file-name-directory nnmail-message-id-cache-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1359 (nnmail-write-region (point-min) (point-max)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1360 nnmail-message-id-cache-file nil 'silent)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (setq nnmail-cache-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 ;;(kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (defun nnmail-cache-insert (id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (when nnmail-treat-duplicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (set-buffer nnmail-cache-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (insert id "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (defun nnmail-cache-id-exists-p (id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (when nnmail-treat-duplicates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (set-buffer nnmail-cache-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (search-backward id nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1380 (defun nnmail-check-duplication (message-id func artnum-func)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1381 (run-hooks 'nnmail-prepare-incoming-message-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ;; If this is a duplicate message, then we do not save it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (let* ((duplication (nnmail-cache-id-exists-p message-id))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1384 (case-fold-search t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (action (when duplication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 ((memq nnmail-treat-duplicates '(warn delete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 nnmail-treat-duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ((nnheader-functionp nnmail-treat-duplicates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (funcall nnmail-treat-duplicates message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1392 nnmail-treat-duplicates))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1393 group-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1394 ;; Let the backend save the article (or not).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 ((not duplication)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (nnmail-cache-insert message-id)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1398 (funcall func (setq group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1399 (nreverse (nnmail-article-group artnum-func)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ((eq action 'delete)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1401 (setq group-art nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ((eq action 'warn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 ;; We insert a warning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (newid (nnmail-message-id)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (when (re-search-forward "^message-id:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (insert "Original-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 "Message-ID: " newid "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 "Gnus-Warning: This is a duplicate of message " message-id "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (nnmail-cache-insert newid)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1415 (funcall func (setq group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1416 (nreverse (nnmail-article-group artnum-func))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (t
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1418 (funcall func (setq group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1419 (nreverse (nnmail-article-group artnum-func))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1420 ;; Add the group-art list to the history list.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1421 (if group-art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1422 (push group-art nnmail-split-history)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1423 (delete-region (point-min) (point-max)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 ;;; Get new mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (defun nnmail-get-value (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (let ((sym (intern (apply 'format args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (when (boundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (symbol-value sym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (defun nnmail-get-new-mail (method exit-func temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 &optional group spool-func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 "Read new incoming mail."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1435 ;; Nix out the previous split history.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1436 (unless group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1437 (setq nnmail-split-history nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (let* ((spools (nnmail-get-spool-files group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (group-in group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 incoming incomings spool)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (when (and (nnmail-get-value "%s-get-new-mail" method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 nnmail-spool-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 ;; We first activate all the groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (nnmail-activate method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 ;; Allow the user to hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (run-hooks 'nnmail-pre-get-new-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; Open the message-id cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (nnmail-cache-open)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ;; The we go through all the existing spool files and split the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; mail from each.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (while spools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (setq spool (pop spools))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 ;; We read each spool file if either the spool is a POP-mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;; spool, or the file exists. We can't check for the
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1455 ;; existence of POPped mail.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (when (or (string-match "^po:" spool)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1457 (and (file-exists-p (file-truename spool))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1458 (> (nnheader-file-size (file-truename spool)) 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (nnheader-message 3 "%s: Reading incoming mail..." method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (when (and (nnmail-move-inbox spool)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (file-exists-p nnmail-crash-box))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; There is new mail. We first find out if all this mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; is supposed to go to some specific group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (setq group (nnmail-get-split-group spool group-in))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; We split the mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (nnmail-split-incoming
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1467 nnmail-crash-box (intern (format "%s-save-mail" method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1468 spool-func group (intern (format "%s-active-number" method)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;; Check whether the inbox is to be moved to the special tmp dir.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (setq incoming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (nnmail-make-complex-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (if nnmail-tmp-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (file-name-as-directory nnmail-tmp-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (file-name-nondirectory (concat temp "Incoming")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (concat temp "Incoming")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (rename-file nnmail-crash-box incoming t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (push incoming incomings))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;; If we did indeed read any incoming spools, we save all info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (when incomings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (nnmail-save-active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (nnmail-get-value "%s-group-alist" method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (nnmail-get-value "%s-active-file" method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (when exit-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (funcall exit-func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (run-hooks 'nnmail-read-incoming-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (nnheader-message 3 "%s: Reading incoming mail...done" method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; Close the message-id cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (nnmail-cache-close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; Allow the user to hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (run-hooks 'nnmail-post-get-new-mail-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 ;; Delete all the temporary files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (while incomings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (setq incoming (pop incomings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (and nnmail-delete-incoming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (file-exists-p incoming)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (file-writable-p incoming)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (delete-file incoming))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (defun nnmail-expired-article-p (group time force &optional inhibit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 "Say whether an article that is TIME old in GROUP should be expired."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (if force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (let ((days (or (and nnmail-expiry-wait-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (funcall nnmail-expiry-wait-function group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 nnmail-expiry-wait)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (cond ((or (eq days 'never)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (and (not force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 inhibit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; This isn't an expirable group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ((eq days 'immediate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;; We expire all articles on sight.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ((equal time '(0 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;; This is an ange-ftp group, and we don't have any dates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 ((numberp days)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (setq days (nnmail-days-to-time days))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 ;; Compare the time with the current time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (nnmail-time-less days (nnmail-time-since time)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (defvar nnmail-read-passwd nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1525 (defun nnmail-read-passwd (prompt &rest args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1526 "Read a password using PROMPT.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1527 If ARGS, PROMPT is used as an argument to `format'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1528 (let ((prompt
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1529 (if args
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1530 (apply 'format prompt args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1531 prompt)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1532 (unless nnmail-read-passwd
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1533 (if (load "passwd" t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1534 (setq nnmail-read-passwd 'read-passwd)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1535 (autoload 'ange-ftp-read-passwd "ange-ftp")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1536 (setq nnmail-read-passwd 'ange-ftp-read-passwd)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1537 (funcall nnmail-read-passwd prompt)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (defun nnmail-check-syntax ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 "Check (and modify) the syntax of the message in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (message-narrow-to-head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (let ((case-fold-search t))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1544 (unless (re-search-forward "^Message-ID:" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (insert "Message-ID: " (nnmail-message-id) "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1547 (defun nnmail-write-region (start end filename &optional append visit lockname)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1548 "Do a `write-region', and then set the file modes."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1549 (write-region start end filename append visit lockname)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1550 (set-file-modes filename nnmail-default-file-modes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1551
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1552 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1553 ;;; Status functions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1554 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1555
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1556 (defun nnmail-replace-status (name value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1557 "Make status NAME and VALUE part of the current status line."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1558 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1559 (message-narrow-to-head)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1560 (let ((status (nnmail-decode-status)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1561 (setq status (delq (member name status) status))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1562 (when value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1563 (push (cons name value) status))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1564 (message-remove-header "status")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1565 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1566 (insert "Status: " (nnmail-encode-status status) "\n"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1567
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1568 (defun nnmail-decode-status ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1569 "Return a status-value alist from STATUS."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1570 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1571 (when (re-search-forward "^Status: " nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1572 (let (name value status)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1573 (save-restriction
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1574 ;; Narrow to the status.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1575 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1576 (point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1577 (if (re-search-forward "^[^ \t]" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1578 (1- (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1579 (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1580 ;; Go through all elements and add them to the list.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1581 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1582 (while (re-search-forward "[^ \t=]+" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1583 (setq name (match-string 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1584 (if (not (= (following-char) ?=))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1585 ;; Implied "yes".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1586 (setq value "yes")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1587 (forward-char 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1588 (if (not (= (following-char) ?\"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1589 (if (not (looking-at "[^ \t]"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1590 ;; Implied "no".
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1591 (setq value "no")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1592 ;; Unquoted value.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1593 (setq value (match-string 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1594 (goto-char (match-end 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1595 ;; Quoted value.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1596 (setq value (read (current-buffer)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1597 (push (cons name value) status)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1598 status)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1599
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1600 (defun nnmail-encode-status (status)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1601 "Return a status string from STATUS."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1602 (mapconcat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1603 (lambda (elem)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1604 (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1605 (car elem) "="
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1606 (if (string-match "[ \t]" (cdr elem))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1607 (prin1-to-string (cdr elem))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1608 (cdr elem))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1609 status " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1610
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1611 (defun nnmail-split-history ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1612 "Generate an overview of where the last mail split put articles."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1613 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1614 (unless nnmail-split-history
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1615 (error "No current split history"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1616 (with-output-to-temp-buffer "*nnmail split history*"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1617 (let ((history nnmail-split-history)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1618 elem)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1619 (while (setq elem (pop history))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1620 (princ (mapconcat (lambda (ga)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1621 (concat (car ga) ":" (int-to-string (cdr ga))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1622 elem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1623 ", "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1624 (princ "\n")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1625
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1626 (defun nnmail-new-mail-p (group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1627 "Say whether GROUP has new mail."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1628 (let ((his nnmail-split-history)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1629 found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1630 (while his
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1631 (when (assoc group (pop his))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1632 (setq found t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1633 his nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1634 found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
1635
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (run-hooks 'nnmail-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (provide 'nnmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ;;; nnmail.el ends here