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