Mercurial > emacs
annotate lisp/gnus/nnmail.el @ 88306:7b65aade5e20
new file, based on Alexander Pohoyda's code.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Tue, 31 Jan 2006 20:53:28 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
17493 | 1 ;;; nnmail.el --- mail support functions for the Gnus mail backends |
88155 | 2 |
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, | |
4 ;; 2004, 2005 Free Software Foundation, Inc. | |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news, mail |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
17493 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Code: | |
29 | |
19522
681265352f07
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
681265352f07
Require cl only at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
31 |
88155 | 32 (require 'gnus) ; for macro gnus-kill-buffer, at least |
17493 | 33 (require 'nnheader) |
34 (require 'message) | |
35 (require 'custom) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
36 (require 'gnus-util) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
37 (require 'mail-source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
38 (require 'mm-util) |
17493 | 39 |
40 (eval-and-compile | |
88155 | 41 (autoload 'gnus-add-buffer "gnus") |
42 (autoload 'gnus-kill-buffer "gnus")) | |
17493 | 43 |
44 (defgroup nnmail nil | |
45 "Reading mail with Gnus." | |
46 :group 'gnus) | |
47 | |
48 (defgroup nnmail-retrieve nil | |
49 "Retrieving new mail." | |
50 :group 'nnmail) | |
51 | |
52 (defgroup nnmail-prepare nil | |
88155 | 53 "Preparing (or mangling) new mail after retrieval." |
17493 | 54 :group 'nnmail) |
55 | |
56 (defgroup nnmail-duplicate nil | |
57 "Handling of duplicate mail messages." | |
58 :group 'nnmail) | |
59 | |
60 (defgroup nnmail-split nil | |
48588 | 61 "Organizing the incoming mail in folders." |
17493 | 62 :group 'nnmail) |
63 | |
64 (defgroup nnmail-files nil | |
65 "Mail files." | |
66 :group 'gnus-files | |
67 :group 'nnmail) | |
68 | |
69 (defgroup nnmail-expire nil | |
70 "Expiring old mail." | |
71 :group 'nnmail) | |
72 | |
73 (defgroup nnmail-procmail nil | |
74 "Interfacing with procmail and other mail agents." | |
75 :group 'nnmail) | |
76 | |
77 (defgroup nnmail-various nil | |
78 "Various mail options." | |
79 :group 'nnmail) | |
80 | |
88155 | 81 (defcustom nnmail-split-methods '(("mail.misc" "")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
82 "*Incoming mail will be split according to this variable. |
17493 | 83 |
84 If you'd like, for instance, one mail group for mail from the | |
85 \"4ad-l\" mailing list, one group for junk mail and one for everything | |
86 else, you could do something like this: | |
87 | |
88 (setq nnmail-split-methods | |
89 '((\"mail.4ad\" \"From:.*4ad\") | |
88155 | 90 (\"mail.junk\" \"From:.*Lars\\\\|Subject:.*buy\") |
91 (\"mail.misc\" \"\"))) | |
17493 | 92 |
93 As you can see, this variable is a list of lists, where the first | |
94 element in each \"rule\" is the name of the group (which, by the way, | |
95 does not have to be called anything beginning with \"mail\", | |
96 \"yonka.zow\" is a fine, fine name), and the second is a regexp that | |
97 nnmail will try to match on the header to find a fit. | |
98 | |
99 The second element can also be a function. In that case, it will be | |
100 called narrowed to the headers with the first element of the rule as | |
101 the argument. It should return a non-nil value if it thinks that the | |
102 mail belongs in that group. | |
103 | |
104 The last element should always have \"\" as the regexp. | |
105 | |
106 This variable can also have a function as its value." | |
107 :group 'nnmail-split | |
88155 | 108 :type '(choice (repeat :tag "Alist" (group (string :tag "Name") |
109 (choice regexp function))) | |
17493 | 110 (function-item nnmail-split-fancy) |
111 (function :tag "Other"))) | |
112 | |
113 ;; Suggested by Erik Selberg <speed@cs.washington.edu>. | |
114 (defcustom nnmail-crosspost t | |
115 "If non-nil, do crossposting if several split methods match the mail. | |
116 If nil, the first match found will be used." | |
117 :group 'nnmail-split | |
118 :type 'boolean) | |
119 | |
88155 | 120 (defcustom nnmail-split-fancy-with-parent-ignore-groups nil |
121 "Regexp that matches group names to be ignored when applying `nnmail-split-fancy-with-parent'. | |
122 This can also be a list of regexps." | |
123 :version "22.1" | |
124 :group 'nnmail-split | |
125 :type '(choice (const :tag "none" nil) | |
126 (regexp :value ".*") | |
127 (repeat :value (".*") regexp))) | |
128 | |
129 (defcustom nnmail-cache-ignore-groups nil | |
130 "Regexp that matches group names to be ignored when inserting message ids into the cache (`nnmail-cache-insert'). | |
131 This can also be a list of regexps." | |
132 :version "22.1" | |
133 :group 'nnmail-split | |
134 :type '(choice (const :tag "none" nil) | |
135 (regexp :value ".*") | |
136 (repeat :value (".*") regexp))) | |
137 | |
17493 | 138 ;; Added by gord@enci.ucalgary.ca (Gordon Matzigkeit). |
139 (defcustom nnmail-keep-last-article nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
140 "If non-nil, nnmail will never delete/move a group's last article. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
141 It can be marked expirable, so it will be deleted when it is no longer last. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
142 |
17493 | 143 You may need to set this variable if other programs are putting |
144 new mail into folder numbers that Gnus has marked as expired." | |
145 :group 'nnmail-procmail | |
146 :group 'nnmail-various | |
147 :type 'boolean) | |
148 | |
149 (defcustom nnmail-use-long-file-names nil | |
150 "If non-nil the mail backends will use long file and directory names. | |
151 If nil, groups like \"mail.misc\" will end up in directories like | |
152 \"mail/misc/\"." | |
153 :group 'nnmail-files | |
154 :type 'boolean) | |
155 | |
156 (defcustom nnmail-default-file-modes 384 | |
157 "Set the mode bits of all new mail files to this integer." | |
158 :group 'nnmail-files | |
159 :type 'integer) | |
160 | |
161 (defcustom nnmail-expiry-wait 7 | |
162 "*Expirable articles that are older than this will be expired. | |
163 This variable can either be a number (which will be interpreted as a | |
164 number of days) -- this doesn't have to be an integer. This variable | |
165 can also be `immediate' and `never'." | |
166 :group 'nnmail-expire | |
167 :type '(choice (const immediate) | |
88155 | 168 (number :tag "days") |
17493 | 169 (const never))) |
170 | |
171 (defcustom nnmail-expiry-wait-function nil | |
172 "Variable that holds function to specify how old articles should be before they are expired. | |
88155 | 173 The function will be called with the name of the group that the expiry |
174 is to be performed in, and it should return an integer that says how | |
175 many days an article can be stored before it is considered \"old\". | |
176 It can also return the values `never' and `immediate'. | |
17493 | 177 |
178 Eg.: | |
179 | |
180 \(setq nnmail-expiry-wait-function | |
181 (lambda (newsgroup) | |
88155 | 182 (cond ((string-match \"private\" newsgroup) 31) |
183 ((string-match \"junk\" newsgroup) 1) | |
17493 | 184 ((string-match \"important\" newsgroup) 'never) |
185 (t 7))))" | |
186 :group 'nnmail-expire | |
187 :type '(choice (const :tag "nnmail-expiry-wait" nil) | |
188 (function :format "%v" nnmail-))) | |
189 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
190 (defcustom nnmail-expiry-target 'delete |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
191 "*Variable that says where expired messages should end up. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
192 The default value is `delete' (which says to delete the messages), |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
193 but it can also be a string or a function. If it is a string, expired |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
194 messages end up in that group. If it is a function, the function is |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
195 called in a buffer narrowed to the message in question. The function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
196 receives one argument, the name of the group the message comes from. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
197 The return value should be `delete' or a group name (a string)." |
33398 | 198 :version "21.1" |
88155 | 199 :group 'nnmail-expire |
200 :type '(choice (const delete) | |
201 (function :format "%v" nnmail-) | |
202 string)) | |
203 | |
204 (defcustom nnmail-fancy-expiry-targets nil | |
205 "Determine expiry target based on articles using fancy techniques. | |
206 | |
207 This is a list of (\"HEADER\" \"REGEXP\" \"TARGET\") entries. If | |
208 `nnmail-expiry-target' is set to the function | |
209 `nnmail-fancy-expiry-target' and HEADER of the article matches REGEXP, | |
210 the message will be expired to a group determined by invoking | |
211 `format-time-string' with TARGET used as the format string and the | |
212 time extracted from the articles' Date header (if missing the current | |
213 time is used). | |
214 | |
215 In the special cases that HEADER is the symbol `to-from', the regexp | |
216 will try to match against both the From and the To header. | |
217 | |
218 Example: | |
219 | |
220 \(setq nnmail-fancy-expiry-targets | |
221 '((to-from \"boss\" \"nnfolder:Work\") | |
222 (\"Subject\" \"IMPORTANT\" \"nnfolder:IMPORTANT.%Y.%b\") | |
223 (\"from\" \".*\" \"nnfolder:Archive-%Y\"))) | |
224 | |
225 In this case, articles containing the string \"boss\" in the To or the | |
226 From header will be expired to the group \"nnfolder:Work\"; | |
227 articles containing the sting \"IMPORTANT\" in the Subject header will | |
228 be expired to the group \"nnfolder:IMPORTANT.YYYY.MMM\"; and | |
229 everything else will be expired to \"nnfolder:Archive-YYYY\"." | |
230 :version "22.1" | |
231 :group 'nnmail-expire | |
232 :type '(repeat (list (choice :tag "Match against" | |
233 (string :tag "Header") | |
234 (const to-from)) | |
235 regexp | |
236 (string :tag "Target group format string")))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
237 |
17493 | 238 (defcustom nnmail-cache-accepted-message-ids nil |
88155 | 239 "If non-nil, put Message-IDs of Gcc'd articles into the duplicate cache. |
240 If non-nil, also update the cache when copy or move articles." | |
17493 | 241 :group 'nnmail |
242 :type 'boolean) | |
243 | |
32101
15d0e4dd8e49
(nnmail-spool-file): Revert to `((file))'.
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
244 (defcustom nnmail-spool-file '((file)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
245 "*Where the mail backends will look for incoming mail. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
246 This variable is a list of mail source specifiers. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
247 This variable is obsolete; `mail-sources' should be used instead." |
17493 | 248 :group 'nnmail-files |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
249 :type 'sexp) |
17493 | 250 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
251 (defcustom nnmail-resplit-incoming nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
252 "*If non-nil, re-split incoming procmail sorted mail." |
17493 | 253 :group 'nnmail-procmail |
254 :type 'boolean) | |
255 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
256 (defcustom nnmail-scan-directory-mail-source-once nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
257 "*If non-nil, scan all incoming procmail sorted mails once. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
258 It scans low-level sorted spools even when not required." |
33398 | 259 :version "21.1" |
17493 | 260 :group 'nnmail-procmail |
261 :type 'boolean) | |
262 | |
263 (defcustom nnmail-delete-file-function 'delete-file | |
264 "Function called to delete files in some mail backends." | |
265 :group 'nnmail-files | |
266 :type 'function) | |
267 | |
268 (defcustom nnmail-crosspost-link-function | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
269 (if (string-match "windows-nt\\|emx" (symbol-name system-type)) |
17493 | 270 'copy-file |
271 'add-name-to-file) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
272 "*Function called to create a copy of a file. |
17493 | 273 This is `add-name-to-file' by default, which means that crossposts |
274 will use hard links. If your file system doesn't allow hard | |
275 links, you could set this variable to `copy-file' instead." | |
276 :group 'nnmail-files | |
277 :type '(radio (function-item add-name-to-file) | |
278 (function-item copy-file) | |
279 (function :tag "Other"))) | |
280 | |
281 (defcustom nnmail-read-incoming-hook | |
282 (if (eq system-type 'windows-nt) | |
283 '(nnheader-ms-strip-cr) | |
284 nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
285 "*Hook that will be run after the incoming mail has been transferred. |
31785 | 286 The incoming mail is moved from the specified spool file (which normally is |
17493 | 287 something like \"/usr/spool/mail/$user\") to the user's home |
288 directory. This hook is called after the incoming mail box has been | |
289 emptied, and can be used to call any mail box programs you have | |
290 running (\"xwatch\", etc.) | |
291 | |
292 Eg. | |
293 | |
294 \(add-hook 'nnmail-read-incoming-hook | |
88155 | 295 (lambda () |
296 (call-process \"/local/bin/mailsend\" nil nil nil | |
297 \"read\" nnmail-spool-file))) | |
17493 | 298 |
299 If you have xwatch running, this will alert it that mail has been | |
300 read. | |
301 | |
302 If you use `display-time', you could use something like this: | |
303 | |
304 \(add-hook 'nnmail-read-incoming-hook | |
305 (lambda () | |
306 ;; Update the displayed time, since that will clear out | |
307 ;; the flag that says you have mail. | |
308 (when (eq (process-status \"display-time\") 'run) | |
309 (display-time-filter display-time-process \"\"))))" | |
310 :group 'nnmail-prepare | |
311 :type 'hook) | |
312 | |
313 (defcustom nnmail-prepare-incoming-hook nil | |
314 "Hook called before treating incoming mail. | |
315 The hook is run in a buffer with all the new, incoming mail." | |
316 :group 'nnmail-prepare | |
317 :type 'hook) | |
318 | |
319 (defcustom nnmail-prepare-incoming-header-hook nil | |
320 "Hook called narrowed to the headers of each message. | |
321 This can be used to remove excessive spaces (and stuff like | |
322 that) from the headers before splitting and saving the messages." | |
323 :group 'nnmail-prepare | |
324 :type 'hook) | |
325 | |
326 (defcustom nnmail-prepare-incoming-message-hook nil | |
327 "Hook called narrowed to each message." | |
328 :group 'nnmail-prepare | |
329 :type 'hook) | |
330 | |
331 (defcustom nnmail-list-identifiers nil | |
332 "Regexp that matches list identifiers to be removed. | |
333 This can also be a list of regexps." | |
334 :group 'nnmail-prepare | |
335 :type '(choice (const :tag "none" nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
336 (regexp :value ".*") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
337 (repeat :value (".*") regexp))) |
17493 | 338 |
339 (defcustom nnmail-pre-get-new-mail-hook nil | |
340 "Hook called just before starting to handle new incoming mail." | |
341 :group 'nnmail-retrieve | |
342 :type 'hook) | |
343 | |
344 (defcustom nnmail-post-get-new-mail-hook nil | |
345 "Hook called just after finishing handling new incoming mail." | |
346 :group 'nnmail-retrieve | |
347 :type 'hook) | |
348 | |
349 (defcustom nnmail-split-hook nil | |
350 "Hook called before deciding where to split an article. | |
351 The functions in this hook are free to modify the buffer | |
352 contents in any way they choose -- the buffer contents are | |
353 discarded after running the split process." | |
354 :group 'nnmail-split | |
355 :type 'hook) | |
356 | |
88155 | 357 (defcustom nnmail-spool-hook nil |
358 "*A hook called when a new article is spooled." | |
359 :version "22.1" | |
360 :group 'nnmail | |
361 :type 'hook) | |
362 | |
17493 | 363 (defcustom nnmail-large-newsgroup 50 |
88155 | 364 "*The number of articles which indicates a large newsgroup or nil. |
365 If the number of articles is greater than the value, verbose | |
17493 | 366 messages will be shown to indicate the current status." |
367 :group 'nnmail-various | |
88155 | 368 :type '(choice (const :tag "infinite" nil) |
369 (number :tag "count"))) | |
370 | |
371 (define-widget 'nnmail-lazy 'default | |
372 "Base widget for recursive datastructures. | |
373 | |
374 This is copy of the `lazy' widget in Emacs 22.1 provided for compatibility." | |
375 :format "%{%t%}: %v" | |
376 :convert-widget 'widget-value-convert-widget | |
377 :value-create (lambda (widget) | |
378 (let ((value (widget-get widget :value)) | |
379 (type (widget-get widget :type))) | |
380 (widget-put widget :children | |
381 (list (widget-create-child-value | |
382 widget (widget-convert type) value))))) | |
383 :value-delete 'widget-children-value-delete | |
384 :value-get (lambda (widget) | |
385 (widget-value (car (widget-get widget :children)))) | |
386 :value-inline (lambda (widget) | |
387 (widget-apply (car (widget-get widget :children)) | |
388 :value-inline)) | |
389 :default-get (lambda (widget) | |
390 (widget-default-get | |
391 (widget-convert (widget-get widget :type)))) | |
392 :match (lambda (widget value) | |
393 (widget-apply (widget-convert (widget-get widget :type)) | |
394 :match value)) | |
395 :validate (lambda (widget) | |
396 (widget-apply (car (widget-get widget :children)) :validate))) | |
397 | |
398 (define-widget 'nnmail-split-fancy 'nnmail-lazy | |
399 "Widget for customizing splits in the variable of the same name." | |
400 :tag "Split" | |
401 :type '(menu-choice :value (any ".*value.*" "misc") | |
402 :tag "Type" | |
403 (string :tag "Destination") | |
404 (list :tag "Use first match (|)" :value (|) | |
405 (const :format "" |) | |
406 (editable-list :inline t nnmail-split-fancy)) | |
407 (list :tag "Use all matches (&)" :value (&) | |
408 (const :format "" &) | |
409 (editable-list :inline t nnmail-split-fancy)) | |
410 (list :tag "Function with fixed arguments (:)" | |
411 :value (: nil) | |
412 (const :format "" :value :) | |
413 function | |
414 (editable-list :inline t (sexp :tag "Arg")) | |
415 ) | |
416 (list :tag "Function with split arguments (!)" | |
417 :value (! nil) | |
418 (const :format "" !) | |
419 function | |
420 (editable-list :inline t nnmail-split-fancy)) | |
421 (list :tag "Field match" | |
422 (choice :tag "Field" | |
423 regexp symbol) | |
424 (choice :tag "Match" | |
425 regexp | |
426 (symbol :value mail)) | |
427 (repeat :inline t | |
428 :tag "Restrictions" | |
429 (group :inline t | |
430 (const :format "" -) | |
431 regexp)) | |
432 nnmail-split-fancy) | |
433 (const :tag "Junk (delete mail)" junk))) | |
17493 | 434 |
435 (defcustom nnmail-split-fancy "mail.misc" | |
436 "Incoming mail can be split according to this fancy variable. | |
437 To enable this, set `nnmail-split-methods' to `nnmail-split-fancy'. | |
438 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
439 The format of this variable is SPLIT, where SPLIT can be one of |
17493 | 440 the following: |
441 | |
442 GROUP: Mail will be stored in GROUP (a string). | |
443 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
444 \(FIELD VALUE [- RESTRICT [- RESTRICT [...]]] SPLIT): If the message |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49274
diff
changeset
|
445 field FIELD (a regexp) contains VALUE (a regexp), store the messages |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
446 as specified by SPLIT. If RESTRICT (a regexp) matches some string |
42206 | 447 after FIELD and before the end of the matched VALUE, return nil, |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
448 otherwise process SPLIT. Multiple RESTRICTs add up, further |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
449 restricting the possibility of processing SPLIT. |
17493 | 450 |
451 \(| SPLIT...): Process each SPLIT expression until one of them matches. | |
452 A SPLIT expression is said to match if it will cause the mail | |
453 message to be stored in one or more groups. | |
454 | |
455 \(& SPLIT...): Process each SPLIT expression. | |
456 | |
457 \(: FUNCTION optional args): Call FUNCTION with the optional args, in | |
458 the buffer containing the message headers. The return value FUNCTION | |
459 should be a split, which is then recursively processed. | |
460 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
461 \(! FUNCTION SPLIT): Call FUNCTION with the result of SPLIT. The |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
462 return value FUNCTION should be a split, which is then recursively |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
463 processed. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
464 |
88155 | 465 junk: Mail will be deleted. Use with care! Do not submerge in water! |
466 Example: | |
467 (setq nnmail-split-fancy | |
468 '(| (\"Subject\" \"MAKE MONEY FAST\" junk) | |
469 ...other.rules.omitted...)) | |
470 | |
17493 | 471 FIELD must match a complete field name. VALUE must match a complete |
472 word according to the `nnmail-split-fancy-syntax-table' syntax table. | |
473 You can use \".*\" in the regexps to match partial field names or words. | |
474 | |
475 FIELD and VALUE can also be lisp symbols, in that case they are expanded | |
476 as specified in `nnmail-split-abbrev-alist'. | |
477 | |
478 GROUP can contain \\& and \\N which will substitute from matching | |
479 \\(\\) patterns in the previous VALUE. | |
480 | |
481 Example: | |
482 | |
483 \(setq nnmail-split-methods 'nnmail-split-fancy | |
484 nnmail-split-fancy | |
485 ;; Messages from the mailer daemon are not crossposted to any of | |
486 ;; the ordinary groups. Warnings are put in a separate group | |
487 ;; from real errors. | |
488 '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\") | |
489 \"mail.misc\")) | |
490 ;; Non-error messages are crossposted to all relevant | |
491 ;; groups, but we don't crosspost between the group for the | |
492 ;; (ding) list and the group for other (ding) related mail. | |
493 (& (| (any \"ding@ifi\\\\.uio\\\\.no\" \"ding.list\") | |
494 (\"subject\" \"ding\" \"ding.misc\")) | |
495 ;; Other mailing lists... | |
496 (any \"procmail@informatik\\\\.rwth-aachen\\\\.de\" \"procmail.list\") | |
497 (any \"SmartList@informatik\\\\.rwth-aachen\\\\.de\" \"SmartList.list\") | |
88155 | 498 ;; Both lists below have the same suffix, so prevent |
499 ;; cross-posting to mkpkg.list of messages posted only to | |
500 ;; the bugs- list, but allow cross-posting when the | |
501 ;; message was really cross-posted. | |
502 (any \"bugs-mypackage@somewhere\" \"mypkg.bugs\") | |
503 (any \"mypackage@somewhere\" - \"bugs-mypackage\" \"mypkg.list\") | |
504 ;; | |
17493 | 505 ;; People... |
506 (any \"larsi@ifi\\\\.uio\\\\.no\" \"people.Lars Magne Ingebrigtsen\")) | |
507 ;; Unmatched mail goes to the catch all group. | |
508 \"misc.misc\"))" | |
509 :group 'nnmail-split | |
88155 | 510 :type 'nnmail-split-fancy) |
17493 | 511 |
512 (defcustom nnmail-split-abbrev-alist | |
513 '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc") | |
514 (mail . "mailer-daemon\\|postmaster\\|uucp") | |
515 (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc") | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
516 (from . "from\\|sender\\|resent-from") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
517 (nato . "to\\|cc\\|resent-to\\|resent-cc") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
518 (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
519 "*Alist of abbreviations allowed in `nnmail-split-fancy'." |
17493 | 520 :group 'nnmail-split |
521 :type '(repeat (cons :format "%v" symbol regexp))) | |
522 | |
523 (defcustom nnmail-message-id-cache-length 1000 | |
524 "*The approximate number of Message-IDs nnmail will keep in its cache. | |
525 If this variable is nil, no checking on duplicate messages will be | |
526 performed." | |
527 :group 'nnmail-duplicate | |
528 :type '(choice (const :tag "disable" nil) | |
529 (integer :format "%v"))) | |
530 | |
531 (defcustom nnmail-message-id-cache-file "~/.nnmail-cache" | |
532 "*The file name of the nnmail Message-ID cache." | |
533 :group 'nnmail-duplicate | |
534 :group 'nnmail-files | |
535 :type 'file) | |
536 | |
537 (defcustom nnmail-treat-duplicates 'warn | |
538 "*If non-nil, nnmail keep a cache of Message-IDs to discover mail duplicates. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
539 Three values are valid: nil, which means that nnmail is not to keep a |
17493 | 540 Message-ID cache; `warn', which means that nnmail should insert extra |
541 headers to warn the user about the duplication (this is the default); | |
542 and `delete', which means that nnmail will delete duplicated mails. | |
543 | |
544 This variable can also be a function. It will be called from a buffer | |
545 narrowed to the article in question with the Message-ID as a | |
546 parameter. It should return nil, `warn' or `delete'." | |
547 :group 'nnmail-duplicate | |
548 :type '(choice (const :tag "off" nil) | |
549 (const warn) | |
550 (const delete))) | |
551 | |
88155 | 552 (defcustom nnmail-extra-headers '(To Newsgroups) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
553 "*Extra headers to parse." |
33398 | 554 :version "21.1" |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
555 :group 'nnmail |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
556 :type '(repeat symbol)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
557 |
88155 | 558 (defcustom nnmail-split-header-length-limit 2048 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
559 "Header lines longer than this limit are excluded from the split function." |
33398 | 560 :version "21.1" |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
561 :group 'nnmail |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
562 :type 'integer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
563 |
88155 | 564 (defcustom nnmail-mail-splitting-charset nil |
565 "Default charset to be used when splitting incoming mail." | |
566 :version "22.1" | |
567 :group 'nnmail | |
568 :type 'symbol) | |
569 | |
570 (defcustom nnmail-mail-splitting-decodes nil | |
571 "Whether the nnmail splitting functionality should MIME decode headers." | |
572 :version "22.1" | |
573 :group 'nnmail | |
574 :type 'boolean) | |
575 | |
576 (defcustom nnmail-split-fancy-match-partial-words nil | |
577 "Whether to match partial words when fancy splitting. | |
578 Normally, regexes given in `nnmail-split-fancy' are implicitly surrounded | |
579 by \"\\=\\<...\\>\". If this variable is true, they are not implicitly\ | |
580 surrounded | |
581 by anything." | |
582 :version "22.1" | |
583 :group 'nnmail | |
584 :type 'boolean) | |
585 | |
586 (defcustom nnmail-split-lowercase-expanded t | |
587 "Whether to lowercase expanded entries (i.e. \\N) when splitting mails. | |
588 This avoids the creation of multiple groups when users send to an address | |
589 using different case (i.e. mailing-list@domain vs Mailing-List@Domain)." | |
590 :version "22.1" | |
591 :group 'nnmail | |
592 :type 'boolean) | |
593 | |
17493 | 594 ;;; Internal variables. |
595 | |
88155 | 596 (defvar nnmail-article-buffer " *nnmail incoming*" |
597 "The buffer used for splitting incoming mails.") | |
598 | |
17493 | 599 (defvar nnmail-split-history nil |
600 "List of group/article elements that say where the previous split put messages.") | |
601 | |
88155 | 602 (defvar nnmail-split-fancy-syntax-table |
603 (let ((table (make-syntax-table))) | |
604 ;; support the %-hack | |
605 (modify-syntax-entry ?\% "." table) | |
606 table) | |
17493 | 607 "Syntax table used by `nnmail-split-fancy'.") |
608 | |
609 (defvar nnmail-prepare-save-mail-hook nil | |
610 "Hook called before saving mail.") | |
611 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
612 (defvar nnmail-split-tracing nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
613 (defvar nnmail-split-trace nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
614 |
17493 | 615 |
616 | |
617 (defun nnmail-request-post (&optional server) | |
618 (mail-send-and-exit nil)) | |
619 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
620 (defvar nnmail-file-coding-system 'raw-text |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
621 "Coding system used in nnmail.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
622 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
623 (defvar nnmail-incoming-coding-system |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
624 mm-text-coding-system |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
625 "Coding system used in reading inbox") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
626 |
38861
f8833aa83b5e
* gnus-art.el (gnus-output-to-file): Bind file-name-coding-system.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
35453
diff
changeset
|
627 (defvar nnmail-pathname-coding-system nil |
49274
eb2699620e9c
* gnus-agent.el: Don't use `path'.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
48588
diff
changeset
|
628 "*Coding system for file name.") |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
629 |
17493 | 630 (defun nnmail-find-file (file) |
631 "Insert FILE in server buffer safely." | |
632 (set-buffer nntp-server-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
633 (delete-region (point-min) (point-max)) |
17493 | 634 (let ((format-alist nil) |
88155 | 635 (after-insert-file-functions nil)) |
17493 | 636 (condition-case () |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
637 (let ((coding-system-for-read nnmail-file-coding-system) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
638 (auto-mode-alist (mm-auto-mode-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
639 (file-name-coding-system nnmail-pathname-coding-system)) |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
640 (insert-file-contents file) |
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
641 t) |
17493 | 642 (file-error nil)))) |
643 | |
644 (defun nnmail-group-pathname (group dir &optional file) | |
49274
eb2699620e9c
* gnus-agent.el: Don't use `path'.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
48588
diff
changeset
|
645 "Make file name for GROUP." |
17493 | 646 (concat |
647 (let ((dir (file-name-as-directory (expand-file-name dir)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
648 (setq group (nnheader-replace-duplicate-chars-in-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
649 (nnheader-replace-chars-in-string group ?/ ?_) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
650 ?. ?_)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
651 (setq group (nnheader-translate-file-chars group)) |
17493 | 652 ;; If this directory exists, we use it directly. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
653 (file-name-as-directory |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
654 (if (or nnmail-use-long-file-names |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
655 (file-directory-p (concat dir group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
656 (expand-file-name group dir) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
657 ;; If not, we translate dots into slashes. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
658 (expand-file-name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
659 (mm-encode-coding-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
660 (nnheader-replace-chars-in-string group ?. ?/) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
661 nnmail-pathname-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
662 dir)))) |
17493 | 663 (or file ""))) |
664 | |
665 (defun nnmail-get-active () | |
666 "Returns an assoc of group names and active ranges. | |
667 nn*-request-list should have been called before calling this function." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
668 ;; Go through all groups from the active list. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
669 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
670 (set-buffer nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
671 (nnmail-parse-active))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
672 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
673 (defun nnmail-parse-active () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
674 "Parse the active file in the current buffer and return an alist." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
675 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
676 (unless (re-search-forward "[\\\"]" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
677 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
678 (while (re-search-backward "[][';?()#]" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
679 (insert ?\\))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
680 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
681 (let ((buffer (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
682 group-assoc group max min) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
683 (while (not (eobp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
684 (condition-case err |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
685 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
686 (narrow-to-region (point) (gnus-point-at-eol)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
687 (setq group (read buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
688 (unless (stringp group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
689 (setq group (symbol-name group))) |
88155 | 690 (if (and (numberp (setq max (read buffer))) |
691 (numberp (setq min (read buffer)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
692 (push (list group (cons min max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
693 group-assoc))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
694 (error nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
695 (widen) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
696 (forward-line 1)) |
17493 | 697 group-assoc)) |
698 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
699 (defvar nnmail-active-file-coding-system 'raw-text |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
700 "*Coding system for active file.") |
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
701 |
17493 | 702 (defun nnmail-save-active (group-assoc file-name) |
703 "Save GROUP-ASSOC in ACTIVE-FILE." | |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
704 (let ((coding-system-for-write nnmail-active-file-coding-system)) |
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
705 (when file-name |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
706 (with-temp-file file-name |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
707 (nnmail-generate-active group-assoc))))) |
17493 | 708 |
709 (defun nnmail-generate-active (alist) | |
710 "Generate an active file from group-alist ALIST." | |
711 (erase-buffer) | |
712 (let (group) | |
713 (while (setq group (pop alist)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
714 (insert (format "%S %d %d y\n" (intern (car group)) (cdadr group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
715 (caadr group)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
716 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
717 (while (search-backward "\\." nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
718 (delete-char 1)))) |
17493 | 719 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
720 (defun nnmail-get-split-group (file source) |
17493 | 721 "Find out whether this FILE is to be split into GROUP only. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
722 If SOURCE is a directory spec, try to return the group name component." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
723 (if (eq (car source) 'directory) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
724 (let ((file (file-name-nondirectory file))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
725 (mail-source-bind (directory source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
726 (if (string-match (concat (regexp-quote suffix) "$") file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
727 (substring file 0 (match-beginning 0)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
728 nil))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
729 nil)) |
17493 | 730 |
731 (defun nnmail-process-babyl-mail-format (func artnum-func) | |
732 (let ((case-fold-search t) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
733 (count 0) |
17493 | 734 start message-id content-length do-search end) |
735 (while (not (eobp)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
736 (goto-char (point-min)) |
17493 | 737 (re-search-forward |
738 "\n0, *unseen,+\n\\(\\*\\*\\* EOOH \\*\\*\\*\n\\)?" nil t) | |
739 (goto-char (match-end 0)) | |
740 (delete-region (match-beginning 0) (match-end 0)) | |
741 (narrow-to-region | |
742 (setq start (point)) | |
743 (progn | |
744 ;; Skip all the headers in case there are more "From "s... | |
745 (or (search-forward "\n\n" nil t) | |
746 (search-forward-regexp "^[^:]*\\( .*\\|\\)$" nil t) | |
747 (search-forward "")) | |
748 (point))) | |
749 ;; Unquote the ">From " line, if any. | |
750 (goto-char (point-min)) | |
751 (when (looking-at ">From ") | |
752 (replace-match "X-From-Line: ") ) | |
753 (run-hooks 'nnmail-prepare-incoming-header-hook) | |
754 (goto-char (point-max)) | |
755 ;; Find the Message-ID header. | |
756 (save-excursion | |
757 (if (re-search-backward | |
758 "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]*>\\)" nil t) | |
759 (setq message-id (buffer-substring (match-beginning 1) | |
760 (match-end 1))) | |
761 ;; There is no Message-ID here, so we create one. | |
762 (save-excursion | |
763 (when (re-search-backward "^Message-ID[ \t]*:" nil t) | |
764 (beginning-of-line) | |
765 (insert "Original-"))) | |
766 (forward-line -1) | |
767 (insert "Message-ID: " (setq message-id (nnmail-message-id)) | |
768 "\n"))) | |
769 ;; Look for a Content-Length header. | |
770 (if (not (save-excursion | |
771 (and (re-search-backward | |
772 "^Content-Length:[ \t]*\\([0-9]+\\)" start t) | |
88155 | 773 (setq content-length (string-to-number |
17493 | 774 (buffer-substring |
775 (match-beginning 1) | |
776 (match-end 1)))) | |
777 ;; We destroy the header, since none of | |
778 ;; the backends ever use it, and we do not | |
779 ;; want to confuse other mailers by having | |
780 ;; a (possibly) faulty header. | |
781 (progn (insert "X-") t)))) | |
782 (setq do-search t) | |
783 (widen) | |
784 (if (or (= (+ (point) content-length) (point-max)) | |
785 (save-excursion | |
786 (goto-char (+ (point) content-length)) | |
787 (looking-at ""))) | |
788 (progn | |
789 (goto-char (+ (point) content-length)) | |
790 (setq do-search nil)) | |
791 (setq do-search t))) | |
792 (widen) | |
793 ;; Go to the beginning of the next article - or to the end | |
794 ;; of the buffer. | |
795 (when do-search | |
796 (if (re-search-forward "^" nil t) | |
797 (goto-char (match-beginning 0)) | |
798 (goto-char (1- (point-max))))) | |
799 (delete-char 1) ; delete ^_ | |
800 (save-excursion | |
801 (save-restriction | |
802 (narrow-to-region start (point)) | |
803 (goto-char (point-min)) | |
804 (nnmail-check-duplication message-id func artnum-func) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
805 (incf count) |
17493 | 806 (setq end (point-max)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
807 (goto-char end)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
808 count)) |
17493 | 809 |
810 (defsubst nnmail-search-unix-mail-delim () | |
811 "Put point at the beginning of the next Unix mbox message." | |
45321
f767f3bf5f86
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
42206
diff
changeset
|
812 ;; Algorithm used to find the next article in the |
17493 | 813 ;; brain-dead Unix mbox format: |
814 ;; | |
815 ;; 1) Search for "^From ". | |
816 ;; 2) If we find it, then see whether the previous | |
817 ;; line is blank and the next line looks like a header. | |
818 ;; Then it's possible that this is a mail delim, and we use it. | |
819 (let ((case-fold-search nil) | |
820 found) | |
821 (while (not found) | |
822 (if (not (re-search-forward "^From " nil t)) | |
823 (setq found 'no) | |
824 (save-excursion | |
825 (beginning-of-line) | |
826 (when (and (or (bobp) | |
827 (save-excursion | |
828 (forward-line -1) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
829 (eq (char-after) ?\n))) |
17493 | 830 (save-excursion |
831 (forward-line 1) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
832 (while (looking-at ">From \\|From ") |
17493 | 833 (forward-line 1)) |
834 (looking-at "[^ \n\t:]+[ \n\t]*:"))) | |
835 (setq found 'yes))))) | |
836 (beginning-of-line) | |
837 (eq found 'yes))) | |
838 | |
839 (defun nnmail-search-unix-mail-delim-backward () | |
840 "Put point at the beginning of the current Unix mbox message." | |
45321
f767f3bf5f86
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
42206
diff
changeset
|
841 ;; Algorithm used to find the next article in the |
17493 | 842 ;; brain-dead Unix mbox format: |
843 ;; | |
844 ;; 1) Search for "^From ". | |
845 ;; 2) If we find it, then see whether the previous | |
846 ;; line is blank and the next line looks like a header. | |
847 ;; Then it's possible that this is a mail delim, and we use it. | |
848 (let ((case-fold-search nil) | |
849 found) | |
850 (while (not found) | |
851 (if (not (re-search-backward "^From " nil t)) | |
852 (setq found 'no) | |
853 (save-excursion | |
854 (beginning-of-line) | |
855 (when (and (or (bobp) | |
856 (save-excursion | |
857 (forward-line -1) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
858 (eq (char-after) ?\n))) |
17493 | 859 (save-excursion |
860 (forward-line 1) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
861 (while (looking-at ">From \\|From ") |
17493 | 862 (forward-line 1)) |
863 (looking-at "[^ \n\t:]+[ \n\t]*:"))) | |
864 (setq found 'yes))))) | |
865 (beginning-of-line) | |
866 (eq found 'yes))) | |
867 | |
868 (defun nnmail-process-unix-mail-format (func artnum-func) | |
869 (let ((case-fold-search t) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
870 (count 0) |
17493 | 871 start message-id content-length end skip head-end) |
872 (goto-char (point-min)) | |
873 (if (not (and (re-search-forward "^From " nil t) | |
874 (goto-char (match-beginning 0)))) | |
875 ;; Possibly wrong format? | |
88155 | 876 (error "Error, unknown mail format! (Possibly corrupted %s `%s'.)" |
877 (if (buffer-file-name) "file" "buffer") | |
878 (or (buffer-file-name) (buffer-name))) | |
17493 | 879 ;; Carry on until the bitter end. |
880 (while (not (eobp)) | |
881 (setq start (point) | |
882 end nil) | |
883 ;; Find the end of the head. | |
884 (narrow-to-region | |
885 start | |
886 (if (search-forward "\n\n" nil t) | |
887 (1- (point)) | |
888 ;; This will never happen, but just to be on the safe side -- | |
889 ;; if there is no head-body delimiter, we search a bit manually. | |
890 (while (and (looking-at "From \\|[^ \t]+:") | |
891 (not (eobp))) | |
892 (forward-line 1)) | |
893 (point))) | |
894 ;; Find the Message-ID header. | |
895 (goto-char (point-min)) | |
896 (if (re-search-forward "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]+>\\)" nil t) | |
897 (setq message-id (match-string 1)) | |
898 (save-excursion | |
899 (when (re-search-forward "^Message-ID[ \t]*:" nil t) | |
900 (beginning-of-line) | |
901 (insert "Original-"))) | |
902 ;; There is no Message-ID here, so we create one. | |
903 (forward-line 1) | |
904 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n")) | |
905 ;; Look for a Content-Length header. | |
906 (goto-char (point-min)) | |
907 (if (not (re-search-forward | |
908 "^Content-Length:[ \t]*\\([0-9]+\\)" nil t)) | |
909 (setq content-length nil) | |
88155 | 910 (setq content-length (string-to-number (match-string 1))) |
17493 | 911 ;; We destroy the header, since none of the backends ever |
912 ;; use it, and we do not want to confuse other mailers by | |
913 ;; having a (possibly) faulty header. | |
914 (beginning-of-line) | |
915 (insert "X-")) | |
916 (run-hooks 'nnmail-prepare-incoming-header-hook) | |
917 ;; Find the end of this article. | |
918 (goto-char (point-max)) | |
919 (widen) | |
920 (setq head-end (point)) | |
921 ;; We try the Content-Length value. The idea: skip over the header | |
922 ;; separator, then check what happens content-length bytes into the | |
48588 | 923 ;; message body. This should be either the end of the buffer, the |
17493 | 924 ;; message separator or a blank line followed by the separator. |
925 ;; The blank line should probably be deleted. If neither of the | |
926 ;; three is met, the content-length header is probably invalid. | |
927 (when content-length | |
928 (forward-line 1) | |
929 (setq skip (+ (point) content-length)) | |
930 (goto-char skip) | |
931 (cond ((or (= skip (point-max)) | |
932 (= (1+ skip) (point-max))) | |
933 (setq end (point-max))) | |
934 ((looking-at "From ") | |
935 (setq end skip)) | |
936 ((looking-at "[ \t]*\n\\(From \\)") | |
937 (setq end (match-beginning 1))) | |
938 (t (setq end nil)))) | |
939 (if end | |
940 (goto-char end) | |
941 ;; No Content-Length, so we find the beginning of the next | |
942 ;; article or the end of the buffer. | |
943 (goto-char head-end) | |
944 (or (nnmail-search-unix-mail-delim) | |
945 (goto-char (point-max)))) | |
946 ;; Allow the backend to save the article. | |
947 (save-excursion | |
948 (save-restriction | |
949 (narrow-to-region start (point)) | |
950 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
951 (incf count) |
17493 | 952 (nnmail-check-duplication message-id func artnum-func) |
953 (setq end (point-max)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
954 (goto-char end))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
955 count)) |
17493 | 956 |
957 (defun nnmail-process-mmdf-mail-format (func artnum-func) | |
958 (let ((delim "^\^A\^A\^A\^A$") | |
959 (case-fold-search t) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
960 (count 0) |
17493 | 961 start message-id end) |
962 (goto-char (point-min)) | |
963 (if (not (and (re-search-forward delim nil t) | |
964 (forward-line 1))) | |
965 ;; Possibly wrong format? | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
966 (error "Error, unknown mail format! (Possibly corrupted.)") |
17493 | 967 ;; Carry on until the bitter end. |
968 (while (not (eobp)) | |
969 (setq start (point)) | |
970 ;; Find the end of the head. | |
971 (narrow-to-region | |
972 start | |
973 (if (search-forward "\n\n" nil t) | |
974 (1- (point)) | |
975 ;; This will never happen, but just to be on the safe side -- | |
976 ;; if there is no head-body delimiter, we search a bit manually. | |
977 (while (and (looking-at "From \\|[^ \t]+:") | |
978 (not (eobp))) | |
979 (forward-line 1)) | |
980 (point))) | |
981 ;; Find the Message-ID header. | |
982 (goto-char (point-min)) | |
983 (if (re-search-forward "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]+>\\)" nil t) | |
984 (setq message-id (match-string 1)) | |
985 ;; There is no Message-ID here, so we create one. | |
986 (save-excursion | |
987 (when (re-search-backward "^Message-ID[ \t]*:" nil t) | |
988 (beginning-of-line) | |
989 (insert "Original-"))) | |
990 (forward-line 1) | |
991 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n")) | |
992 (run-hooks 'nnmail-prepare-incoming-header-hook) | |
993 ;; Find the end of this article. | |
994 (goto-char (point-max)) | |
995 (widen) | |
996 (if (re-search-forward delim nil t) | |
997 (beginning-of-line) | |
998 (goto-char (point-max))) | |
999 ;; Allow the backend to save the article. | |
1000 (save-excursion | |
1001 (save-restriction | |
1002 (narrow-to-region start (point)) | |
1003 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1004 (incf count) |
17493 | 1005 (nnmail-check-duplication message-id func artnum-func) |
1006 (setq end (point-max)))) | |
1007 (goto-char end) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1008 (forward-line 2))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1009 count)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1010 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1011 (defun nnmail-process-maildir-mail-format (func artnum-func) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1012 ;; In a maildir, every file contains exactly one mail. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1013 (let ((case-fold-search t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1014 message-id) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1015 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1016 ;; Find the end of the head. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1017 (narrow-to-region |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1018 (point-min) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1019 (if (search-forward "\n\n" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1020 (1- (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1021 ;; This will never happen, but just to be on the safe side -- |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1022 ;; if there is no head-body delimiter, we search a bit manually. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1023 (while (and (looking-at "From \\|[^ \t]+:") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1024 (not (eobp))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1025 (forward-line 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1026 (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1027 ;; Find the Message-ID header. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1028 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1029 (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1030 (setq message-id (match-string 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1031 ;; There is no Message-ID here, so we create one. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1032 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1033 (when (re-search-backward "^Message-ID[ \t]*:" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1034 (beginning-of-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1035 (insert "Original-"))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1036 (forward-line 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1037 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1038 (run-hooks 'nnmail-prepare-incoming-header-hook) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1039 ;; Allow the backend to save the article. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1040 (widen) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1041 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1042 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1043 (nnmail-check-duplication message-id func artnum-func)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1044 1)) |
17493 | 1045 |
1046 (defun nnmail-split-incoming (incoming func &optional exit-func | |
1047 group artnum-func) | |
1048 "Go through the entire INCOMING file and pick out each individual mail. | |
1049 FUNC will be called with the buffer narrowed to each mail." | |
88155 | 1050 (let ( ;; If this is a group-specific split, we bind the split |
17493 | 1051 ;; methods to just this group. |
1052 (nnmail-split-methods (if (and group | |
1053 (not nnmail-resplit-incoming)) | |
1054 (list (list group "")) | |
1055 nnmail-split-methods))) | |
1056 (save-excursion | |
1057 ;; Insert the incoming file. | |
88155 | 1058 (set-buffer (get-buffer-create nnmail-article-buffer)) |
17493 | 1059 (erase-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1060 (let ((coding-system-for-read nnmail-incoming-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1061 (mm-insert-file-contents incoming)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1062 (prog1 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1063 (if (zerop (buffer-size)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1064 0 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1065 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1066 (save-excursion (run-hooks 'nnmail-prepare-incoming-hook)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1067 ;; Handle both babyl, MMDF and unix mail formats, since |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1068 ;; movemail will use the former when fetching from a |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1069 ;; mailbox, the latter when fetching from a file. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1070 (cond ((or (looking-at "\^L") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1071 (looking-at "BABYL OPTIONS:")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1072 (nnmail-process-babyl-mail-format func artnum-func)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1073 ((looking-at "\^A\^A\^A\^A") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1074 (nnmail-process-mmdf-mail-format func artnum-func)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1075 ((looking-at "Return-Path:") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1076 (nnmail-process-maildir-mail-format func artnum-func)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1077 (t |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1078 (nnmail-process-unix-mail-format func artnum-func)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1079 (when exit-func |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1080 (funcall exit-func)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1081 (kill-buffer (current-buffer)))))) |
17493 | 1082 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1083 (defun nnmail-article-group (func &optional trace) |
17493 | 1084 "Look at the headers and return an alist of groups that match. |
1085 FUNC will be called with the group name to determine the article number." | |
88155 | 1086 (let ((methods (or nnmail-split-methods '(("bogus" "")))) |
17493 | 1087 (obuf (current-buffer)) |
88155 | 1088 group-art method grp) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1089 (if (and (sequencep methods) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1090 (= (length methods) 1)) |
17493 | 1091 ;; If there is only just one group to put everything in, we |
1092 ;; just return a list with just this one method in. | |
1093 (setq group-art | |
1094 (list (cons (caar methods) (funcall func (caar methods))))) | |
1095 ;; We do actual comparison. | |
1096 (save-excursion | |
88155 | 1097 ;; Copy the article into the work buffer. |
17493 | 1098 (set-buffer nntp-server-buffer) |
1099 (erase-buffer) | |
88155 | 1100 (insert-buffer-substring obuf) |
1101 ;; Narrow to headers. | |
1102 (narrow-to-region | |
1103 (goto-char (point-min)) | |
1104 (if (search-forward "\n\n" nil t) | |
1105 (point) | |
1106 (point-max))) | |
1107 (goto-char (point-min)) | |
1108 ;; Decode MIME headers and charsets. | |
1109 (when nnmail-mail-splitting-decodes | |
1110 (let ((mail-parse-charset nnmail-mail-splitting-charset)) | |
1111 (mail-decode-encoded-word-region (point-min) (point-max)))) | |
17493 | 1112 ;; Fold continuation lines. |
1113 (goto-char (point-min)) | |
1114 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t) | |
1115 (replace-match " " t t)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1116 ;; Nuke pathologically long headers. Since Gnus applies |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1117 ;; pathologically complex regexps to the buffer, lines |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1118 ;; that are looong will take longer than the Universe's |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1119 ;; existence to process. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1120 (goto-char (point-min)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1121 (while (not (eobp)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1122 (unless (< (move-to-column nnmail-split-header-length-limit) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1123 nnmail-split-header-length-limit) |
88155 | 1124 (delete-region (point) (gnus-point-at-eol))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1125 (forward-line 1)) |
17493 | 1126 ;; Allow washing. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1127 (goto-char (point-min)) |
17493 | 1128 (run-hooks 'nnmail-split-hook) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1129 (when (setq nnmail-split-tracing trace) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1130 (setq nnmail-split-trace nil)) |
17493 | 1131 (if (and (symbolp nnmail-split-methods) |
1132 (fboundp nnmail-split-methods)) | |
1133 (let ((split | |
1134 (condition-case nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1135 ;; `nnmail-split-methods' is a function, so we |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1136 ;; just call this function here and use the |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1137 ;; result. |
17493 | 1138 (or (funcall nnmail-split-methods) |
1139 '("bogus")) | |
1140 (error | |
88155 | 1141 (nnheader-message |
1142 5 "Error in `nnmail-split-methods'; using `bogus' mail group") | |
17493 | 1143 (sit-for 1) |
1144 '("bogus"))))) | |
88155 | 1145 (setq split (mm-delete-duplicates split)) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1146 ;; The article may be "cross-posted" to `junk'. What |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1147 ;; to do? Just remove the `junk' spec. Don't really |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1148 ;; see anything else to do... |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1149 (let (elem) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1150 (while (setq elem (car (memq 'junk split))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1151 (setq split (delq elem split)))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1152 (when split |
17493 | 1153 (setq group-art |
1154 (mapcar | |
1155 (lambda (group) (cons group (funcall func group))) | |
1156 split)))) | |
1157 ;; Go through the split methods to find a match. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1158 (while (and methods |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1159 (or nnmail-crosspost |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1160 (not group-art))) |
17493 | 1161 (goto-char (point-max)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1162 (setq method (pop methods) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1163 grp (car method)) |
17493 | 1164 (if (or methods |
1165 (not (equal "" (nth 1 method)))) | |
1166 (when (and | |
1167 (ignore-errors | |
1168 (if (stringp (nth 1 method)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1169 (let ((expand (string-match "\\\\[0-9&]" grp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1170 (pos (re-search-backward (cadr method) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1171 nil t))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1172 (and expand |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1173 (setq grp (nnmail-expand-newtext grp))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1174 pos) |
17493 | 1175 ;; Function to say whether this is a match. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1176 (funcall (nth 1 method) grp))) |
17493 | 1177 ;; Don't enter the article into the same |
1178 ;; group twice. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1179 (not (assoc grp group-art))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1180 (push (cons grp (funcall func grp)) |
17493 | 1181 group-art)) |
1182 ;; This is the final group, which is used as a | |
1183 ;; catch-all. | |
1184 (unless group-art | |
1185 (setq group-art | |
1186 (list (cons (car method) | |
88155 | 1187 (funcall func (car method)))))))) |
1188 ;; Fall back on "bogus" if all else fails. | |
1189 (unless group-art | |
1190 (setq group-art (list (cons "bogus" (funcall func "bogus")))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1191 ;; Produce a trace if non-empty. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1192 (when (and trace nnmail-split-trace) |
88155 | 1193 (let ((restore (current-buffer))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1194 (nnheader-set-temp-buffer "*Split Trace*") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1195 (gnus-add-buffer) |
88155 | 1196 (dolist (trace (nreverse nnmail-split-trace)) |
1197 (prin1 trace (current-buffer)) | |
1198 (insert "\n")) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1199 (goto-char (point-min)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1200 (gnus-configure-windows 'split-trace) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1201 (set-buffer restore))) |
88155 | 1202 (widen) |
17493 | 1203 ;; See whether the split methods returned `junk'. |
1204 (if (equal group-art '(junk)) | |
1205 nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1206 ;; The article may be "cross-posted" to `junk'. What |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1207 ;; to do? Just remove the `junk' spec. Don't really |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1208 ;; see anything else to do... |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1209 (let (elem) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1210 (while (setq elem (car (memq 'junk group-art))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1211 (setq group-art (delq elem group-art))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19593
diff
changeset
|
1212 (nreverse group-art))))))) |
17493 | 1213 |
1214 (defun nnmail-insert-lines () | |
1215 "Insert how many lines there are in the body of the mail. | |
1216 Return the number of characters in the body." | |
1217 (let (lines chars) | |
1218 (save-excursion | |
1219 (goto-char (point-min)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49274
diff
changeset
|
1220 (unless (search-forward "\n\n" nil t) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1221 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1222 (insert "\n")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1223 (setq chars (- (point-max) (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1224 (setq lines (count-lines (point) (point-max))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1225 (forward-char -1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1226 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1227 (when (re-search-backward "^Lines: " nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1228 (delete-region (point) (progn (forward-line 1) (point))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1229 (beginning-of-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1230 (insert (format "Lines: %d\n" (max lines 0))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1231 chars))) |
17493 | 1232 |
1233 (defun nnmail-insert-xref (group-alist) | |
1234 "Insert an Xref line based on the (group . article) alist." | |
1235 (save-excursion | |
1236 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1237 (unless (search-forward "\n\n" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1238 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1239 (insert "\n")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1240 (forward-char -1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1241 (when (re-search-backward "^Xref: " nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1242 (delete-region (match-beginning 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1243 (progn (forward-line 1) (point)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1244 (insert (format "Xref: %s" (system-name))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1245 (while group-alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1246 (insert (format " %s:%d" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1247 (mm-encode-coding-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1248 (caar group-alist) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1249 nnmail-pathname-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1250 (cdar group-alist))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1251 (setq group-alist (cdr group-alist))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1252 (insert "\n"))) |
17493 | 1253 |
1254 ;;; Message washing functions | |
1255 | |
1256 (defun nnmail-remove-leading-whitespace () | |
1257 "Remove excessive whitespace from all headers." | |
1258 (goto-char (point-min)) | |
1259 (while (re-search-forward "^\\([^ :]+: \\) +" nil t) | |
1260 (replace-match "\\1" t))) | |
1261 | |
1262 (defun nnmail-remove-list-identifiers () | |
1263 "Remove list identifiers from Subject headers." | |
88155 | 1264 (let ((regexp |
1265 (if (consp nnmail-list-identifiers) | |
1266 (mapconcat 'identity nnmail-list-identifiers " *\\|") | |
1267 nnmail-list-identifiers))) | |
17493 | 1268 (when regexp |
1269 (goto-char (point-min)) | |
88155 | 1270 (while (re-search-forward |
1271 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)") | |
1272 nil t) | |
1273 (delete-region (match-beginning 2) (match-end 0)) | |
1274 (beginning-of-line)) | |
1275 (when (re-search-forward "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" | |
1276 nil t) | |
1277 (delete-region (match-beginning 1) (match-end 1)) | |
1278 (beginning-of-line))))) | |
17493 | 1279 |
1280 (defun nnmail-remove-tabs () | |
1281 "Translate TAB characters into SPACE characters." | |
1282 (subst-char-in-region (point-min) (point-max) ?\t ? t)) | |
1283 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1284 (defun nnmail-fix-eudora-headers () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1285 "Eudora has a broken References line, but an OK In-Reply-To." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1286 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1287 (when (re-search-forward "^X-Mailer:.*Eudora" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1288 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1289 (when (re-search-forward "^References:" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1290 (beginning-of-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1291 (insert "X-Gnus-Broken-Eudora-")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1292 (goto-char (point-min)) |
88155 | 1293 (when (re-search-forward "^\\(In-Reply-To:[^\n]+\\)\n[ \t]+" nil t) |
1294 (replace-match "\\1" t)))) | |
17493 | 1295 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1296 (custom-add-option 'nnmail-prepare-incoming-header-hook |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1297 'nnmail-fix-eudora-headers) |
17493 | 1298 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1299 ;;; Utility functions |
17493 | 1300 |
88155 | 1301 (defun nnmail-do-request-post (accept-func &optional server) |
1302 "Utility function to directly post a message to an nnmail-derived group. | |
1303 Calls ACCEPT-FUNC (which should be `nnchoke-request-accept-article') | |
1304 to actually put the message in the right group." | |
1305 (let ((success t)) | |
1306 (dolist (mbx (message-unquote-tokens | |
1307 (message-tokenize-header | |
1308 (message-fetch-field "Newsgroups") ", ")) success) | |
1309 (let ((to-newsgroup (gnus-group-prefixed-name mbx gnus-command-method))) | |
1310 (or (gnus-active to-newsgroup) | |
1311 (gnus-activate-group to-newsgroup) | |
1312 (if (gnus-y-or-n-p (format "No such group: %s. Create it? " | |
1313 to-newsgroup)) | |
1314 (or (and (gnus-request-create-group | |
1315 to-newsgroup gnus-command-method) | |
1316 (gnus-activate-group to-newsgroup nil nil | |
1317 gnus-command-method)) | |
1318 (error "Couldn't create group %s" to-newsgroup))) | |
1319 (error "No such group: %s" to-newsgroup)) | |
1320 (unless (funcall accept-func mbx (nth 1 gnus-command-method)) | |
1321 (setq success nil)))))) | |
1322 | |
17493 | 1323 (defun nnmail-split-fancy () |
1324 "Fancy splitting method. | |
88155 | 1325 See the documentation for the variable `nnmail-split-fancy' for details." |
17493 | 1326 (let ((syntab (syntax-table))) |
1327 (unwind-protect | |
1328 (progn | |
1329 (set-syntax-table nnmail-split-fancy-syntax-table) | |
1330 (nnmail-split-it nnmail-split-fancy)) | |
1331 (set-syntax-table syntab)))) | |
1332 | |
1333 (defvar nnmail-split-cache nil) | |
1334 ;; Alist of split expressions their equivalent regexps. | |
1335 | |
1336 (defun nnmail-split-it (split) | |
1337 ;; Return a list of groups matching SPLIT. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1338 (let (cached-pair) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1339 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1340 ;; nil split |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1341 ((null split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1342 nil) |
17493 | 1343 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1344 ;; A group name. Do the \& and \N subs into the string. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1345 ((stringp split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1346 (when nnmail-split-tracing |
88155 | 1347 (push split nnmail-split-trace)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1348 (list (nnmail-expand-newtext split))) |
17493 | 1349 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1350 ;; Junk the message. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1351 ((eq split 'junk) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1352 (when nnmail-split-tracing |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1353 (push "junk" nnmail-split-trace)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1354 (list 'junk)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1355 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1356 ;; Builtin & operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1357 ((eq (car split) '&) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1358 (apply 'nconc (mapcar 'nnmail-split-it (cdr split)))) |
17493 | 1359 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1360 ;; Builtin | operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1361 ((eq (car split) '|) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1362 (let (done) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1363 (while (and (not done) (cdr split)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1364 (setq split (cdr split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1365 done (nnmail-split-it (car split)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1366 done)) |
17493 | 1367 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1368 ;; Builtin : operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1369 ((eq (car split) ':) |
88155 | 1370 (when nnmail-split-tracing |
1371 (push split nnmail-split-trace)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1372 (nnmail-split-it (save-excursion (eval (cdr split))))) |
17493 | 1373 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1374 ;; Builtin ! operation. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1375 ((eq (car split) '!) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1376 (funcall (cadr split) (nnmail-split-it (caddr split)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1377 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1378 ;; Check the cache for the regexp for this split. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1379 ((setq cached-pair (assq split nnmail-split-cache)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1380 (let (split-result |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1381 (end-point (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1382 (value (nth 1 split))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1383 (if (symbolp value) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1384 (setq value (cdr (assq value nnmail-split-abbrev-alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1385 (while (and (goto-char end-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1386 (re-search-backward (cdr cached-pair) nil t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1387 (when nnmail-split-tracing |
88155 | 1388 (push split nnmail-split-trace)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1389 (let ((split-rest (cddr split)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1390 (end (match-end 0)) |
88155 | 1391 ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\). |
1392 ;; So, start-of-value is the point just before the | |
1393 ;; beginning of the value, whereas after-header-name | |
1394 ;; is the point just after the field name. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1395 (start-of-value (match-end 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1396 (after-header-name (match-end 2))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1397 ;; Start the next search just before the beginning of the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1398 ;; VALUE match. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1399 (setq end-point (1- start-of-value)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1400 ;; Handle - RESTRICTs |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1401 (while (eq (car split-rest) '-) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1402 ;; RESTRICT must start after-header-name and |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1403 ;; end after start-of-value, so that, for |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1404 ;; (any "foo" - "x-foo" "foo.list") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1405 ;; we do not exclude foo.list just because |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1406 ;; the header is: ``To: x-foo, foo'' |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1407 (goto-char end) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1408 (if (and (re-search-backward (cadr split-rest) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1409 after-header-name t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1410 (> (match-end 0) start-of-value)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1411 (setq split-rest nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1412 (setq split-rest (cddr split-rest)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1413 (when split-rest |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1414 (goto-char end) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1415 (let ((value (nth 1 split))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1416 (if (symbolp value) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1417 (setq value (cdr (assq value nnmail-split-abbrev-alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1418 ;; Someone might want to do a \N sub on this match, so get the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1419 ;; correct match positions. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1420 (re-search-backward value start-of-value)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1421 (dolist (sp (nnmail-split-it (car split-rest))) |
88155 | 1422 (unless (member sp split-result) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1423 (push sp split-result)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1424 split-result)) |
17493 | 1425 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1426 ;; Not in cache, compute a regexp for the field/value pair. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1427 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1428 (let* ((field (nth 0 split)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1429 (value (nth 1 split)) |
88155 | 1430 partial-front |
1431 partial-rear | |
1432 regexp) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1433 (if (symbolp value) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1434 (setq value (cdr (assq value nnmail-split-abbrev-alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1435 (if (and (>= (length value) 2) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1436 (string= ".*" (substring value 0 2))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1437 (setq value (substring value 2) |
88155 | 1438 partial-front "")) |
1439 ;; Same trick for the rear of the regexp | |
1440 (if (and (>= (length value) 2) | |
1441 (string= ".*" (substring value -2))) | |
1442 (setq value (substring value 0 -2) | |
1443 partial-rear "")) | |
1444 (when nnmail-split-fancy-match-partial-words | |
1445 (setq partial-front "" | |
1446 partial-rear "")) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1447 (setq regexp (concat "^\\(\\(" |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1448 (if (symbolp field) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1449 (cdr (assq field nnmail-split-abbrev-alist)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1450 field) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1451 "\\):.*\\)" |
88155 | 1452 (or partial-front "\\<") |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1453 "\\(" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1454 value |
88155 | 1455 "\\)" |
1456 (or partial-rear "\\>"))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1457 (push (cons split regexp) nnmail-split-cache) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1458 ;; Now that it's in the cache, just call nnmail-split-it again |
88155 | 1459 ;; on the same split, which will find it immediately in the cache. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1460 (nnmail-split-it split)))))) |
17493 | 1461 |
1462 (defun nnmail-expand-newtext (newtext) | |
1463 (let ((len (length newtext)) | |
1464 (pos 0) | |
1465 c expanded beg N did-expand) | |
1466 (while (< pos len) | |
1467 (setq beg pos) | |
1468 (while (and (< pos len) | |
1469 (not (= (aref newtext pos) ?\\))) | |
1470 (setq pos (1+ pos))) | |
1471 (unless (= beg pos) | |
1472 (push (substring newtext beg pos) expanded)) | |
1473 (when (< pos len) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1474 ;; We hit a \; expand it. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1475 (setq did-expand t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1476 pos (1+ pos) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1477 c (aref newtext pos)) |
17493 | 1478 (if (not (or (= c ?\&) |
1479 (and (>= c ?1) | |
1480 (<= c ?9)))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1481 ;; \ followed by some character we don't expand. |
17493 | 1482 (push (char-to-string c) expanded) |
1483 ;; \& or \N | |
1484 (if (= c ?\&) | |
1485 (setq N 0) | |
1486 (setq N (- c ?0))) | |
1487 (when (match-beginning N) | |
88155 | 1488 (push (if nnmail-split-lowercase-expanded |
1489 (downcase (buffer-substring (match-beginning N) | |
1490 (match-end N))) | |
1491 (buffer-substring (match-beginning N) (match-end N))) | |
17493 | 1492 expanded)))) |
1493 (setq pos (1+ pos))) | |
1494 (if did-expand | |
1495 (apply 'concat (nreverse expanded)) | |
1496 newtext))) | |
1497 | |
1498 ;; Activate a backend only if it isn't already activated. | |
1499 ;; If FORCE, re-read the active file even if the backend is | |
1500 ;; already activated. | |
1501 (defun nnmail-activate (backend &optional force) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1502 (nnheader-init-server-buffer) |
17493 | 1503 (let (file timestamp file-time) |
1504 (if (or (not (symbol-value (intern (format "%s-group-alist" backend)))) | |
1505 force | |
1506 (and (setq file (ignore-errors | |
1507 (symbol-value (intern (format "%s-active-file" | |
1508 backend))))) | |
1509 (setq file-time (nth 5 (file-attributes file))) | |
1510 (or (not | |
1511 (setq timestamp | |
1512 (condition-case () | |
1513 (symbol-value (intern | |
1514 (format "%s-active-timestamp" | |
1515 backend))) | |
1516 (error 'none)))) | |
1517 (not (consp timestamp)) | |
1518 (equal timestamp '(0 0)) | |
1519 (> (nth 0 file-time) (nth 0 timestamp)) | |
1520 (and (= (nth 0 file-time) (nth 0 timestamp)) | |
1521 (> (nth 1 file-time) (nth 1 timestamp)))))) | |
1522 (save-excursion | |
1523 (or (eq timestamp 'none) | |
1524 (set (intern (format "%s-active-timestamp" backend)) | |
1525 file-time)) | |
1526 (funcall (intern (format "%s-request-list" backend))))) | |
1527 t)) | |
1528 | |
1529 (defun nnmail-message-id () | |
1530 (concat "<" (message-unique-id) "@totally-fudged-out-message-id>")) | |
1531 | |
1532 ;;; | |
1533 ;;; nnmail duplicate handling | |
1534 ;;; | |
1535 | |
1536 (defvar nnmail-cache-buffer nil) | |
1537 | |
1538 (defun nnmail-cache-open () | |
1539 (if (or (not nnmail-treat-duplicates) | |
1540 (and nnmail-cache-buffer | |
1541 (buffer-name nnmail-cache-buffer))) | |
1542 () ; The buffer is open. | |
1543 (save-excursion | |
1544 (set-buffer | |
1545 (setq nnmail-cache-buffer | |
1546 (get-buffer-create " *nnmail message-id cache*"))) | |
88155 | 1547 (gnus-add-buffer) |
17493 | 1548 (when (file-exists-p nnmail-message-id-cache-file) |
1549 (nnheader-insert-file-contents nnmail-message-id-cache-file)) | |
1550 (set-buffer-modified-p nil) | |
1551 (current-buffer)))) | |
1552 | |
1553 (defun nnmail-cache-close () | |
1554 (when (and nnmail-cache-buffer | |
1555 nnmail-treat-duplicates | |
1556 (buffer-name nnmail-cache-buffer) | |
1557 (buffer-modified-p nnmail-cache-buffer)) | |
1558 (save-excursion | |
1559 (set-buffer nnmail-cache-buffer) | |
1560 ;; Weed out the excess number of Message-IDs. | |
1561 (goto-char (point-max)) | |
1562 (when (search-backward "\n" nil t nnmail-message-id-cache-length) | |
1563 (progn | |
1564 (beginning-of-line) | |
1565 (delete-region (point-min) (point)))) | |
1566 ;; Save the buffer. | |
1567 (or (file-exists-p (file-name-directory nnmail-message-id-cache-file)) | |
1568 (make-directory (file-name-directory nnmail-message-id-cache-file) | |
1569 t)) | |
1570 (nnmail-write-region (point-min) (point-max) | |
1571 nnmail-message-id-cache-file nil 'silent) | |
1572 (set-buffer-modified-p nil) | |
1573 (setq nnmail-cache-buffer nil) | |
88155 | 1574 (gnus-kill-buffer (current-buffer))))) |
17493 | 1575 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1576 ;; Compiler directives. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1577 (defvar group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1578 (defvar group-art-list) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1579 (defvar group-art) |
88155 | 1580 (defun nnmail-cache-insert (id grp &optional subject sender) |
1581 (when (stringp id) | |
1582 ;; this will handle cases like `B r' where the group is nil | |
1583 (let ((grp (or grp gnus-newsgroup-name "UNKNOWN"))) | |
1584 (run-hook-with-args 'nnmail-spool-hook | |
1585 id grp subject sender)) | |
1586 (when nnmail-treat-duplicates | |
1587 ;; Store some information about the group this message is written | |
1588 ;; to. This is passed in as the grp argument -- all locations this | |
1589 ;; has been called from have been checked and the group is available. | |
1590 ;; The only ambiguous case is nnmail-check-duplication which will only | |
1591 ;; pass the first (of possibly >1) group which matches. -Josh | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1592 (unless (gnus-buffer-live-p nnmail-cache-buffer) |
88155 | 1593 (nnmail-cache-open)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1594 (save-excursion |
88155 | 1595 (set-buffer nnmail-cache-buffer) |
1596 (goto-char (point-max)) | |
1597 (if (and grp (not (string= "" grp)) | |
1598 (gnus-methods-equal-p gnus-command-method | |
1599 (nnmail-cache-primary-mail-backend))) | |
1600 (let ((regexp (if (consp nnmail-cache-ignore-groups) | |
1601 (mapconcat 'identity nnmail-cache-ignore-groups | |
1602 "\\|") | |
1603 nnmail-cache-ignore-groups))) | |
1604 (unless (and regexp (string-match regexp grp)) | |
1605 (insert id "\t" grp "\n"))) | |
1606 (insert id "\n")))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1607 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1608 (defun nnmail-cache-primary-mail-backend () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1609 (let ((be-list (cons gnus-select-method gnus-secondary-select-methods)) |
88155 | 1610 (be nil) |
1611 (res nil) | |
1612 (get-new-mail nil)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1613 (while (and (null res) be-list) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1614 (setq be (car be-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1615 (setq be-list (cdr be-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1616 (when (and (gnus-method-option-p be 'respool) |
88155 | 1617 (setq get-new-mail |
1618 (intern (format "%s-get-new-mail" (car be)))) | |
1619 (boundp get-new-mail) | |
1620 (symbol-value get-new-mail)) | |
1621 (setq res be))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1622 res)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1623 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1624 ;; Fetch the group name corresponding to the message id stored in the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1625 ;; cache. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1626 (defun nnmail-cache-fetch-group (id) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1627 (when (and nnmail-treat-duplicates nnmail-cache-buffer) |
17493 | 1628 (save-excursion |
1629 (set-buffer nnmail-cache-buffer) | |
1630 (goto-char (point-max)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1631 (when (search-backward id nil t) |
88155 | 1632 (beginning-of-line) |
1633 (skip-chars-forward "^\n\r\t") | |
1634 (unless (looking-at "[\r\n]") | |
1635 (forward-char 1) | |
1636 (buffer-substring (point) (gnus-point-at-eol))))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1637 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1638 ;; Function for nnmail-split-fancy: look up all references in the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1639 ;; cache and if a match is found, return that group. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1640 (defun nnmail-split-fancy-with-parent () |
88155 | 1641 "Split this message into the same group as its parent. |
1642 This function can be used as an entry in `nnmail-split-fancy', for | |
1643 example like this: (: nnmail-split-fancy-with-parent) | |
1644 For a message to be split, it looks for the parent message in the | |
1645 References or In-Reply-To header and then looks in the message id | |
1646 cache file (given by the variable `nnmail-message-id-cache-file') to | |
1647 see which group that message was put in. This group is returned. | |
1648 | |
1649 See the Info node `(gnus)Fancy Mail Splitting' for more details." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1650 (let* ((refstr (or (message-fetch-field "references") |
88155 | 1651 (message-fetch-field "in-reply-to"))) |
1652 (references nil) | |
1653 (res nil) | |
1654 (regexp (if (consp nnmail-split-fancy-with-parent-ignore-groups) | |
1655 (mapconcat | |
1656 (lambda (x) (format "\\(%s\\)" x)) | |
1657 nnmail-split-fancy-with-parent-ignore-groups | |
1658 "\\|") | |
1659 nnmail-split-fancy-with-parent-ignore-groups))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1660 (when refstr |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1661 (setq references (nreverse (gnus-split-references refstr))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1662 (unless (gnus-buffer-live-p nnmail-cache-buffer) |
88155 | 1663 (nnmail-cache-open)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1664 (mapcar (lambda (x) |
88155 | 1665 (setq res (or (nnmail-cache-fetch-group x) res)) |
1666 (when (or (member res '("delayed" "drafts" "queue")) | |
1667 (and regexp res (string-match regexp res))) | |
1668 (setq res nil))) | |
1669 references) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1670 res))) |
17493 | 1671 |
1672 (defun nnmail-cache-id-exists-p (id) | |
1673 (when nnmail-treat-duplicates | |
1674 (save-excursion | |
1675 (set-buffer nnmail-cache-buffer) | |
1676 (goto-char (point-max)) | |
1677 (search-backward id nil t)))) | |
1678 | |
1679 (defun nnmail-fetch-field (header) | |
1680 (save-excursion | |
1681 (save-restriction | |
1682 (message-narrow-to-head) | |
1683 (message-fetch-field header)))) | |
1684 | |
1685 (defun nnmail-check-duplication (message-id func artnum-func) | |
1686 (run-hooks 'nnmail-prepare-incoming-message-hook) | |
1687 ;; If this is a duplicate message, then we do not save it. | |
1688 (let* ((duplication (nnmail-cache-id-exists-p message-id)) | |
1689 (case-fold-search t) | |
1690 (action (when duplication | |
1691 (cond | |
1692 ((memq nnmail-treat-duplicates '(warn delete)) | |
1693 nnmail-treat-duplicates) | |
88155 | 1694 ((functionp nnmail-treat-duplicates) |
17493 | 1695 (funcall nnmail-treat-duplicates message-id)) |
1696 (t | |
1697 nnmail-treat-duplicates)))) | |
1698 group-art) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1699 ;; We insert a line that says what the mail source is. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1700 (let ((case-fold-search t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1701 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1702 (re-search-forward "^message-id[ \t]*:" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1703 (beginning-of-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1704 (insert (format "X-Gnus-Mail-Source: %s\n" mail-source-string))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1705 |
17493 | 1706 ;; Let the backend save the article (or not). |
1707 (cond | |
1708 ((not duplication) | |
1709 (funcall func (setq group-art | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1710 (nreverse (nnmail-article-group artnum-func)))) |
88155 | 1711 (nnmail-cache-insert message-id (caar group-art))) |
17493 | 1712 ((eq action 'delete) |
1713 (setq group-art nil)) | |
1714 ((eq action 'warn) | |
1715 ;; We insert a warning. | |
1716 (let ((case-fold-search t)) | |
1717 (goto-char (point-min)) | |
1718 (re-search-forward "^message-id[ \t]*:" nil t) | |
1719 (beginning-of-line) | |
1720 (insert | |
1721 "Gnus-Warning: This is a duplicate of message " message-id "\n") | |
1722 (funcall func (setq group-art | |
1723 (nreverse (nnmail-article-group artnum-func)))))) | |
1724 (t | |
1725 (funcall func (setq group-art | |
1726 (nreverse (nnmail-article-group artnum-func)))))) | |
1727 ;; Add the group-art list to the history list. | |
1728 (if group-art | |
1729 (push group-art nnmail-split-history) | |
1730 (delete-region (point-min) (point-max))))) | |
1731 | |
1732 ;;; Get new mail. | |
1733 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1734 (defvar nnmail-fetched-sources nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1735 |
17493 | 1736 (defun nnmail-get-value (&rest args) |
1737 (let ((sym (intern (apply 'format args)))) | |
1738 (when (boundp sym) | |
1739 (symbol-value sym)))) | |
1740 | |
1741 (defun nnmail-get-new-mail (method exit-func temp | |
1742 &optional group spool-func) | |
1743 "Read new incoming mail." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1744 (let* ((sources (or mail-sources |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1745 (if (listp nnmail-spool-file) nnmail-spool-file |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1746 (list nnmail-spool-file)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1747 fetching-sources |
17493 | 1748 (group-in group) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1749 (i 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1750 (new 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1751 (total 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1752 incoming incomings source) |
31785 | 1753 (when (and (nnmail-get-value "%s-get-new-mail" method) |
1754 sources) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1755 (while (setq source (pop sources)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1756 ;; Be compatible with old values. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1757 (cond |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1758 ((stringp source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1759 (setq source |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1760 (cond |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1761 ((string-match "^po:" source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1762 (list 'pop :user (substring source (match-end 0)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1763 ((file-directory-p source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1764 (list 'directory :path source)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1765 (t |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1766 (list 'file :path source))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1767 ((eq source 'procmail) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1768 (message "Invalid value for nnmail-spool-file: `procmail'") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1769 nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1770 ;; Hack to only fetch the contents of a single group's spool file. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1771 (when (and (eq (car source) 'directory) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1772 (null nnmail-scan-directory-mail-source-once) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1773 group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1774 (mail-source-bind (directory source) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1775 (setq source (append source |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1776 (list |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1777 :predicate |
88155 | 1778 (gnus-byte-compile |
1779 `(lambda (file) | |
1780 (string-equal | |
1781 ,(concat group suffix) | |
1782 (file-name-nondirectory file))))))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1783 (when nnmail-fetched-sources |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1784 (if (member source nnmail-fetched-sources) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1785 (setq source nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1786 (push source nnmail-fetched-sources) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1787 (push source fetching-sources))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1788 (when fetching-sources |
17493 | 1789 ;; We first activate all the groups. |
1790 (nnmail-activate method) | |
1791 ;; Allow the user to hook. | |
1792 (run-hooks 'nnmail-pre-get-new-mail-hook) | |
1793 ;; Open the message-id cache. | |
1794 (nnmail-cache-open) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1795 ;; The we go through all the existing mail source specification |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1796 ;; and fetch the mail from each. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1797 (while (setq source (pop fetching-sources)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1798 (nnheader-message 4 "%s: Reading incoming mail from %s..." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1799 method (car source)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1800 (when (setq new |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1801 (mail-source-fetch |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1802 source |
88155 | 1803 (gnus-byte-compile |
1804 `(lambda (file orig-file) | |
1805 (nnmail-split-incoming | |
1806 file ',(intern (format "%s-save-mail" method)) | |
1807 ',spool-func | |
1808 (if (equal file orig-file) | |
1809 nil | |
1810 (nnmail-get-split-group orig-file ',source)) | |
1811 ',(intern (format "%s-active-number" method))))))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1812 (incf total new) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1813 (incf i))) |
17493 | 1814 ;; If we did indeed read any incoming spools, we save all info. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1815 (if (zerop total) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1816 (nnheader-message 4 "%s: Reading incoming mail (no new mail)...done" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1817 method (car source)) |
17493 | 1818 (nnmail-save-active |
1819 (nnmail-get-value "%s-group-alist" method) | |
1820 (nnmail-get-value "%s-active-file" method)) | |
1821 (when exit-func | |
1822 (funcall exit-func)) | |
1823 (run-hooks 'nnmail-read-incoming-hook) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1824 (nnheader-message 4 "%s: Reading incoming mail (%d new)...done" method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1825 total)) |
17493 | 1826 ;; Close the message-id cache. |
1827 (nnmail-cache-close) | |
1828 ;; Allow the user to hook. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1829 (run-hooks 'nnmail-post-get-new-mail-hook)))) |
17493 | 1830 |
1831 (defun nnmail-expired-article-p (group time force &optional inhibit) | |
1832 "Say whether an article that is TIME old in GROUP should be expired." | |
1833 (if force | |
1834 t | |
1835 (let ((days (or (and nnmail-expiry-wait-function | |
1836 (funcall nnmail-expiry-wait-function group)) | |
1837 nnmail-expiry-wait))) | |
1838 (cond ((or (eq days 'never) | |
1839 (and (not force) | |
1840 inhibit)) | |
1841 ;; This isn't an expirable group. | |
1842 nil) | |
1843 ((eq days 'immediate) | |
1844 ;; We expire all articles on sight. | |
1845 t) | |
1846 ((equal time '(0 0)) | |
88155 | 1847 ;; This is an ange-ftp group, and we don't have any dates. |
17493 | 1848 nil) |
1849 ((numberp days) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1850 (setq days (days-to-time days)) |
17493 | 1851 ;; Compare the time with the current time. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1852 (ignore-errors (time-less-p days (time-since time)))))))) |
17493 | 1853 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1854 (defun nnmail-expiry-target-group (target group) |
88155 | 1855 ;; Do not invoke this from nntp-server-buffer! At least nnfolder clears |
1856 ;; that buffer if the nnfolder group isn't selected. | |
1857 (let (nnmail-cache-accepted-message-ids) | |
1858 ;; Don't enter Message-IDs into cache. | |
1859 ;; Let users hack it in TARGET function. | |
1860 (when (functionp target) | |
1861 (setq target (funcall target group))) | |
1862 (unless (eq target 'delete) | |
1863 (when (or (gnus-request-group target) | |
1864 (gnus-request-create-group target)) | |
1865 (let ((group-art (gnus-request-accept-article target nil nil t))) | |
1866 (when (consp group-art) | |
1867 (gnus-group-mark-article-read target (cdr group-art)))))))) | |
1868 | |
1869 (defun nnmail-fancy-expiry-target (group) | |
1870 "Returns a target expiry group determined by `nnmail-fancy-expiry-targets'." | |
1871 (let* (header | |
1872 (case-fold-search nil) | |
1873 (from (or (message-fetch-field "from") "")) | |
1874 (to (or (message-fetch-field "to") "")) | |
1875 (date (message-fetch-field "date")) | |
1876 (target 'delete)) | |
1877 (setq date (if date | |
1878 (condition-case err | |
1879 (date-to-time date) | |
1880 (error | |
1881 (message "%s" (error-message-string err)) | |
1882 (current-time))) | |
1883 (current-time))) | |
1884 (dolist (regexp-target-pair (reverse nnmail-fancy-expiry-targets) target) | |
1885 (setq header (car regexp-target-pair)) | |
1886 (cond | |
1887 ;; If the header is to-from then match against the | |
1888 ;; To or From header | |
1889 ((and (equal header 'to-from) | |
1890 (or (string-match (cadr regexp-target-pair) from) | |
1891 (and (string-match message-dont-reply-to-names from) | |
1892 (string-match (cadr regexp-target-pair) to)))) | |
1893 (setq target (format-time-string (caddr regexp-target-pair) date))) | |
1894 ((and (not (equal header 'to-from)) | |
1895 (string-match (cadr regexp-target-pair) | |
1896 (or | |
1897 (message-fetch-field header) | |
1898 ""))) | |
1899 (setq target | |
1900 (format-time-string (caddr regexp-target-pair) date))))))) | |
17493 | 1901 |
1902 (defun nnmail-check-syntax () | |
1903 "Check (and modify) the syntax of the message in the current buffer." | |
1904 (save-restriction | |
1905 (message-narrow-to-head) | |
1906 (let ((case-fold-search t)) | |
1907 (unless (re-search-forward "^Message-ID[ \t]*:" nil t) | |
1908 (insert "Message-ID: " (nnmail-message-id) "\n"))))) | |
1909 | |
1910 (defun nnmail-write-region (start end filename &optional append visit lockname) | |
1911 "Do a `write-region', and then set the file modes." | |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
1912 (let ((coding-system-for-write nnmail-file-coding-system) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1913 (file-name-coding-system nnmail-pathname-coding-system)) |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
1914 (write-region start end filename append visit lockname) |
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
1915 (set-file-modes filename nnmail-default-file-modes))) |
17493 | 1916 |
1917 ;;; | |
1918 ;;; Status functions | |
1919 ;;; | |
1920 | |
1921 (defun nnmail-replace-status (name value) | |
1922 "Make status NAME and VALUE part of the current status line." | |
1923 (save-restriction | |
1924 (message-narrow-to-head) | |
1925 (let ((status (nnmail-decode-status))) | |
1926 (setq status (delq (member name status) status)) | |
1927 (when value | |
1928 (push (cons name value) status)) | |
1929 (message-remove-header "status") | |
1930 (goto-char (point-max)) | |
1931 (insert "Status: " (nnmail-encode-status status) "\n")))) | |
1932 | |
1933 (defun nnmail-decode-status () | |
1934 "Return a status-value alist from STATUS." | |
1935 (goto-char (point-min)) | |
1936 (when (re-search-forward "^Status: " nil t) | |
1937 (let (name value status) | |
1938 (save-restriction | |
1939 ;; Narrow to the status. | |
1940 (narrow-to-region | |
1941 (point) | |
1942 (if (re-search-forward "^[^ \t]" nil t) | |
1943 (1- (point)) | |
1944 (point-max))) | |
1945 ;; Go through all elements and add them to the list. | |
1946 (goto-char (point-min)) | |
1947 (while (re-search-forward "[^ \t=]+" nil t) | |
1948 (setq name (match-string 0)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1949 (if (not (eq (char-after) ?=)) |
17493 | 1950 ;; Implied "yes". |
1951 (setq value "yes") | |
1952 (forward-char 1) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1953 (if (not (eq (char-after) ?\")) |
17493 | 1954 (if (not (looking-at "[^ \t]")) |
1955 ;; Implied "no". | |
1956 (setq value "no") | |
1957 ;; Unquoted value. | |
1958 (setq value (match-string 0)) | |
1959 (goto-char (match-end 0))) | |
1960 ;; Quoted value. | |
1961 (setq value (read (current-buffer))))) | |
1962 (push (cons name value) status))) | |
1963 status))) | |
1964 | |
1965 (defun nnmail-encode-status (status) | |
1966 "Return a status string from STATUS." | |
1967 (mapconcat | |
1968 (lambda (elem) | |
1969 (concat | |
1970 (car elem) "=" | |
1971 (if (string-match "[ \t]" (cdr elem)) | |
1972 (prin1-to-string (cdr elem)) | |
1973 (cdr elem)))) | |
1974 status " ")) | |
1975 | |
1976 (defun nnmail-split-history () | |
1977 "Generate an overview of where the last mail split put articles." | |
1978 (interactive) | |
1979 (unless nnmail-split-history | |
1980 (error "No current split history")) | |
1981 (with-output-to-temp-buffer "*nnmail split history*" | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1982 (with-current-buffer standard-output |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
26039
diff
changeset
|
1983 (fundamental-mode)) ; for Emacs 20.4+ |
17493 | 1984 (let ((history nnmail-split-history) |
1985 elem) | |
1986 (while (setq elem (pop history)) | |
1987 (princ (mapconcat (lambda (ga) | |
1988 (concat (car ga) ":" (int-to-string (cdr ga)))) | |
1989 elem | |
1990 ", ")) | |
1991 (princ "\n"))))) | |
1992 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1993 (defun nnmail-purge-split-history (group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1994 "Remove all instances of GROUP from `nnmail-split-history'." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1995 (let ((history nnmail-split-history)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1996 (while history |
88155 | 1997 (setcar history (gnus-remove-if (lambda (e) (string= (car e) group)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1998 (car history))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1999 (pop history)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2000 (setq nnmail-split-history (delq nil nnmail-split-history)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2001 |
17493 | 2002 (defun nnmail-new-mail-p (group) |
2003 "Say whether GROUP has new mail." | |
2004 (let ((his nnmail-split-history) | |
2005 found) | |
2006 (while his | |
2007 (when (assoc group (pop his)) | |
2008 (setq found t | |
2009 his nil))) | |
2010 found)) | |
2011 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2012 (defun nnmail-within-headers-p () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2013 "Check to see if point is within the headers of a unix mail message. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2014 Doesn't change point." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2015 (let ((pos (point))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2016 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2017 (and (nnmail-search-unix-mail-delim-backward) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2018 (not (search-forward "\n\n" pos t)))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
2019 |
17493 | 2020 (run-hooks 'nnmail-load-hook) |
2021 | |
2022 (provide 'nnmail) | |
2023 | |
88155 | 2024 ;;; arch-tag: fe8f671a-50db-428a-bb5d-f00462f72ed7 |
17493 | 2025 ;;; nnmail.el ends here |