Mercurial > emacs
annotate lisp/gnus/nnmail.el @ 30002:edb654a13bf1
(dabbrev--find-expansion): Use walk-windows instead
of cycling through windows with next-window.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 03 Jul 2000 09:13:06 +0000 |
parents | fb6b9c37cdc4 |
children | 9968f55ad26e |
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 | |
1242 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
1243 | |
1244 (defun nnmail-split-fancy () | |
1245 "Fancy splitting method. | |
1246 See the documentation for the variable `nnmail-split-fancy' for documentation." | |
1247 (let ((syntab (syntax-table))) | |
1248 (unwind-protect | |
1249 (progn | |
1250 (set-syntax-table nnmail-split-fancy-syntax-table) | |
1251 (nnmail-split-it nnmail-split-fancy)) | |
1252 (set-syntax-table syntab)))) | |
1253 | |
1254 (defvar nnmail-split-cache nil) | |
1255 ;; Alist of split expressions their equivalent regexps. | |
1256 | |
1257 (defun nnmail-split-it (split) | |
1258 ;; 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
|
1259 (let (cached-pair) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1260 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1261 ;; nil split |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1262 ((null split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1263 nil) |
17493 | 1264 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1265 ;; 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
|
1266 ((stringp split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1267 (when nnmail-split-tracing |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1268 (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
|
1269 (list (nnmail-expand-newtext split))) |
17493 | 1270 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1271 ;; Junk the message. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1272 ((eq split 'junk) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1273 (when nnmail-split-tracing |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1274 (push "junk" nnmail-split-trace)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1275 (list 'junk)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1276 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1277 ;; Builtin & operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1278 ((eq (car split) '&) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1279 (apply 'nconc (mapcar 'nnmail-split-it (cdr split)))) |
17493 | 1280 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1281 ;; Builtin | operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1282 ((eq (car split) '|) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1283 (let (done) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1284 (while (and (not done) (cdr split)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1285 (setq split (cdr split) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1286 done (nnmail-split-it (car split)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1287 done)) |
17493 | 1288 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1289 ;; Builtin : operation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1290 ((eq (car split) ':) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1291 (nnmail-split-it (save-excursion (eval (cdr split))))) |
17493 | 1292 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1293 ;; 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
|
1294 ((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
|
1295 (goto-char (point-max)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1296 ;; 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
|
1297 ;; 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
|
1298 ;; 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
|
1299 ;; '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
|
1300 ;; 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
|
1301 ;; 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
|
1302 ;; when there are two different matches. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1303 ;; 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
|
1304 ;; 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
|
1305 ;; 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
|
1306 ;; 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
|
1307 ;; 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
|
1308 ;; 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
|
1309 ;; 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
|
1310 (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
|
1311 (when nnmail-split-tracing |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1312 (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
|
1313 ;; 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
|
1314 ;; correct match positions. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1315 (goto-char (match-end 0)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1316 (let ((value (nth 1 split))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1317 (re-search-backward (if (symbolp value) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1318 (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
|
1319 value) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1320 (match-end 1))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1321 (nnmail-split-it (nth 2 split)))) |
17493 | 1322 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1323 ;; 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
|
1324 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1325 (let* ((field (nth 0 split)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1326 (value (nth 1 split)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1327 (regexp (concat "^\\(\\(" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1328 (if (symbolp field) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1329 (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
|
1330 field) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1331 "\\):.*\\)\\<\\(" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1332 (if (symbolp value) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1333 (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
|
1334 value) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1335 "\\)\\>"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1336 (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
|
1337 ;; 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
|
1338 ;; 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
|
1339 (nnmail-split-it split)))))) |
17493 | 1340 |
1341 (defun nnmail-expand-newtext (newtext) | |
1342 (let ((len (length newtext)) | |
1343 (pos 0) | |
1344 c expanded beg N did-expand) | |
1345 (while (< pos len) | |
1346 (setq beg pos) | |
1347 (while (and (< pos len) | |
1348 (not (= (aref newtext pos) ?\\))) | |
1349 (setq pos (1+ pos))) | |
1350 (unless (= beg pos) | |
1351 (push (substring newtext beg pos) expanded)) | |
1352 (when (< pos len) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1353 ;; We hit a \; expand it. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1354 (setq did-expand t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1355 pos (1+ pos) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1356 c (aref newtext pos)) |
17493 | 1357 (if (not (or (= c ?\&) |
1358 (and (>= c ?1) | |
1359 (<= c ?9)))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1360 ;; \ followed by some character we don't expand. |
17493 | 1361 (push (char-to-string c) expanded) |
1362 ;; \& or \N | |
1363 (if (= c ?\&) | |
1364 (setq N 0) | |
1365 (setq N (- c ?0))) | |
1366 (when (match-beginning N) | |
1367 (push (buffer-substring (match-beginning N) (match-end N)) | |
1368 expanded)))) | |
1369 (setq pos (1+ pos))) | |
1370 (if did-expand | |
1371 (apply 'concat (nreverse expanded)) | |
1372 newtext))) | |
1373 | |
1374 ;; Get a list of spool files to read. | |
1375 (defun nnmail-get-spool-files (&optional group) | |
1376 (if (null nnmail-spool-file) | |
1377 ;; No spool file whatsoever. | |
1378 nil | |
1379 (let* ((procmails | |
1380 ;; If procmail is used to get incoming mail, the files | |
1381 ;; are stored in this directory. | |
1382 (and (file-exists-p nnmail-procmail-directory) | |
1383 (or (eq nnmail-spool-file 'procmail) | |
1384 nnmail-use-procmail) | |
1385 (directory-files | |
1386 nnmail-procmail-directory | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1387 t (concat (if group (concat "^" (regexp-quote group)) "") |
17493 | 1388 nnmail-procmail-suffix "$")))) |
1389 (p procmails) | |
1390 (crash (when (and (file-exists-p nnmail-crash-box) | |
1391 (> (nnheader-file-size | |
1392 (file-truename nnmail-crash-box)) | |
1393 0)) | |
1394 (list nnmail-crash-box)))) | |
1395 ;; Remove any directories that inadvertently match the procmail | |
1396 ;; suffix, which might happen if the suffix is "". | |
1397 (while p | |
1398 (when (file-directory-p (car p)) | |
1399 (setq procmails (delete (car p) procmails))) | |
1400 (setq p (cdr p))) | |
1401 ;; Return the list of spools. | |
1402 (append | |
1403 crash | |
1404 (cond ((and group | |
1405 (or (eq nnmail-spool-file 'procmail) | |
1406 nnmail-use-procmail) | |
1407 procmails) | |
1408 procmails) | |
1409 ((and group | |
1410 (eq nnmail-spool-file 'procmail)) | |
1411 nil) | |
1412 ((listp nnmail-spool-file) | |
1413 (nconc | |
1414 (apply | |
1415 'nconc | |
1416 (mapcar | |
1417 (lambda (file) | |
1418 (if (and (not (string-match "^po:" file)) | |
1419 (file-directory-p file)) | |
1420 (nnheader-directory-regular-files file) | |
1421 (list file))) | |
1422 nnmail-spool-file)) | |
1423 procmails)) | |
1424 ((stringp nnmail-spool-file) | |
1425 (if (and (not (string-match "^po:" nnmail-spool-file)) | |
1426 (file-directory-p nnmail-spool-file)) | |
1427 (nconc | |
1428 (nnheader-directory-regular-files nnmail-spool-file) | |
1429 procmails) | |
1430 (cons nnmail-spool-file procmails))) | |
1431 ((eq nnmail-spool-file 'pop) | |
1432 (cons (format "po:%s" (user-login-name)) procmails)) | |
1433 (t | |
1434 procmails)))))) | |
1435 | |
1436 ;; Activate a backend only if it isn't already activated. | |
1437 ;; If FORCE, re-read the active file even if the backend is | |
1438 ;; already activated. | |
1439 (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
|
1440 (nnheader-init-server-buffer) |
17493 | 1441 (let (file timestamp file-time) |
1442 (if (or (not (symbol-value (intern (format "%s-group-alist" backend)))) | |
1443 force | |
1444 (and (setq file (ignore-errors | |
1445 (symbol-value (intern (format "%s-active-file" | |
1446 backend))))) | |
1447 (setq file-time (nth 5 (file-attributes file))) | |
1448 (or (not | |
1449 (setq timestamp | |
1450 (condition-case () | |
1451 (symbol-value (intern | |
1452 (format "%s-active-timestamp" | |
1453 backend))) | |
1454 (error 'none)))) | |
1455 (not (consp timestamp)) | |
1456 (equal timestamp '(0 0)) | |
1457 (> (nth 0 file-time) (nth 0 timestamp)) | |
1458 (and (= (nth 0 file-time) (nth 0 timestamp)) | |
1459 (> (nth 1 file-time) (nth 1 timestamp)))))) | |
1460 (save-excursion | |
1461 (or (eq timestamp 'none) | |
1462 (set (intern (format "%s-active-timestamp" backend)) | |
1463 file-time)) | |
1464 (funcall (intern (format "%s-request-list" backend))))) | |
1465 t)) | |
1466 | |
1467 (defun nnmail-message-id () | |
1468 (concat "<" (message-unique-id) "@totally-fudged-out-message-id>")) | |
1469 | |
1470 ;;; | |
1471 ;;; nnmail duplicate handling | |
1472 ;;; | |
1473 | |
1474 (defvar nnmail-cache-buffer nil) | |
1475 | |
1476 (defun nnmail-cache-open () | |
1477 (if (or (not nnmail-treat-duplicates) | |
1478 (and nnmail-cache-buffer | |
1479 (buffer-name nnmail-cache-buffer))) | |
1480 () ; The buffer is open. | |
1481 (save-excursion | |
1482 (set-buffer | |
1483 (setq nnmail-cache-buffer | |
1484 (get-buffer-create " *nnmail message-id cache*"))) | |
1485 (buffer-disable-undo (current-buffer)) | |
1486 (when (file-exists-p nnmail-message-id-cache-file) | |
1487 (nnheader-insert-file-contents nnmail-message-id-cache-file)) | |
1488 (set-buffer-modified-p nil) | |
1489 (current-buffer)))) | |
1490 | |
1491 (defun nnmail-cache-close () | |
1492 (when (and nnmail-cache-buffer | |
1493 nnmail-treat-duplicates | |
1494 (buffer-name nnmail-cache-buffer) | |
1495 (buffer-modified-p nnmail-cache-buffer)) | |
1496 (save-excursion | |
1497 (set-buffer nnmail-cache-buffer) | |
1498 ;; Weed out the excess number of Message-IDs. | |
1499 (goto-char (point-max)) | |
1500 (when (search-backward "\n" nil t nnmail-message-id-cache-length) | |
1501 (progn | |
1502 (beginning-of-line) | |
1503 (delete-region (point-min) (point)))) | |
1504 ;; Save the buffer. | |
1505 (or (file-exists-p (file-name-directory nnmail-message-id-cache-file)) | |
1506 (make-directory (file-name-directory nnmail-message-id-cache-file) | |
1507 t)) | |
1508 (nnmail-write-region (point-min) (point-max) | |
1509 nnmail-message-id-cache-file nil 'silent) | |
1510 (set-buffer-modified-p nil) | |
1511 (setq nnmail-cache-buffer nil) | |
1512 (kill-buffer (current-buffer))))) | |
1513 | |
1514 (defun nnmail-cache-insert (id) | |
1515 (when nnmail-treat-duplicates | |
1516 (unless (gnus-buffer-live-p nnmail-cache-buffer) | |
1517 (nnmail-cache-open)) | |
1518 (save-excursion | |
1519 (set-buffer nnmail-cache-buffer) | |
1520 (goto-char (point-max)) | |
1521 (insert id "\n")))) | |
1522 | |
1523 (defun nnmail-cache-id-exists-p (id) | |
1524 (when nnmail-treat-duplicates | |
1525 (save-excursion | |
1526 (set-buffer nnmail-cache-buffer) | |
1527 (goto-char (point-max)) | |
1528 (search-backward id nil t)))) | |
1529 | |
1530 (defun nnmail-fetch-field (header) | |
1531 (save-excursion | |
1532 (save-restriction | |
1533 (message-narrow-to-head) | |
1534 (message-fetch-field header)))) | |
1535 | |
1536 (defun nnmail-check-duplication (message-id func artnum-func) | |
1537 (run-hooks 'nnmail-prepare-incoming-message-hook) | |
1538 ;; If this is a duplicate message, then we do not save it. | |
1539 (let* ((duplication (nnmail-cache-id-exists-p message-id)) | |
1540 (case-fold-search t) | |
1541 (action (when duplication | |
1542 (cond | |
1543 ((memq nnmail-treat-duplicates '(warn delete)) | |
1544 nnmail-treat-duplicates) | |
1545 ((nnheader-functionp nnmail-treat-duplicates) | |
1546 (funcall nnmail-treat-duplicates message-id)) | |
1547 (t | |
1548 nnmail-treat-duplicates)))) | |
1549 group-art) | |
1550 ;; Let the backend save the article (or not). | |
1551 (cond | |
1552 ((not duplication) | |
1553 (nnmail-cache-insert message-id) | |
1554 (funcall func (setq group-art | |
1555 (nreverse (nnmail-article-group artnum-func))))) | |
1556 ((eq action 'delete) | |
1557 (setq group-art nil)) | |
1558 ((eq action 'warn) | |
1559 ;; We insert a warning. | |
1560 (let ((case-fold-search t)) | |
1561 (goto-char (point-min)) | |
1562 (re-search-forward "^message-id[ \t]*:" nil t) | |
1563 (beginning-of-line) | |
1564 (insert | |
1565 "Gnus-Warning: This is a duplicate of message " message-id "\n") | |
1566 (funcall func (setq group-art | |
1567 (nreverse (nnmail-article-group artnum-func)))))) | |
1568 (t | |
1569 (funcall func (setq group-art | |
1570 (nreverse (nnmail-article-group artnum-func)))))) | |
1571 ;; Add the group-art list to the history list. | |
1572 (if group-art | |
1573 (push group-art nnmail-split-history) | |
1574 (delete-region (point-min) (point-max))))) | |
1575 | |
1576 ;;; Get new mail. | |
1577 | |
1578 (defun nnmail-get-value (&rest args) | |
1579 (let ((sym (intern (apply 'format args)))) | |
1580 (when (boundp sym) | |
1581 (symbol-value sym)))) | |
1582 | |
1583 (defun nnmail-get-new-mail (method exit-func temp | |
1584 &optional group spool-func) | |
1585 "Read new incoming mail." | |
1586 (let* ((spools (nnmail-get-spool-files group)) | |
1587 (group-in group) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1588 nnmail-current-spool incoming incomings spool) |
17493 | 1589 (when (and (nnmail-get-value "%s-get-new-mail" method) |
1590 nnmail-spool-file) | |
1591 ;; We first activate all the groups. | |
1592 (nnmail-activate method) | |
1593 ;; Allow the user to hook. | |
1594 (run-hooks 'nnmail-pre-get-new-mail-hook) | |
1595 ;; Open the message-id cache. | |
1596 (nnmail-cache-open) | |
1597 ;; The we go through all the existing spool files and split the | |
1598 ;; mail from each. | |
1599 (while spools | |
1600 (setq spool (pop spools)) | |
1601 ;; We read each spool file if either the spool is a POP-mail | |
1602 ;; spool, or the file exists. We can't check for the | |
1603 ;; existence of POPped mail. | |
1604 (when (or (string-match "^po:" spool) | |
1605 (and (file-exists-p (file-truename spool)) | |
1606 (> (nnheader-file-size (file-truename spool)) 0))) | |
1607 (nnheader-message 3 "%s: Reading incoming mail..." method) | |
1608 (when (and (nnmail-move-inbox spool) | |
1609 (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
|
1610 (setq nnmail-current-spool spool) |
17493 | 1611 ;; There is new mail. We first find out if all this mail |
1612 ;; is supposed to go to some specific group. | |
1613 (setq group (nnmail-get-split-group spool group-in)) | |
1614 ;; We split the mail | |
1615 (nnmail-split-incoming | |
1616 nnmail-crash-box (intern (format "%s-save-mail" method)) | |
1617 spool-func group (intern (format "%s-active-number" method))) | |
1618 ;; Check whether the inbox is to be moved to the special tmp dir. | |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24600
diff
changeset
|
1619 (let ((prefix |
17493 | 1620 (expand-file-name |
1621 (if nnmail-tmp-directory | |
1622 (concat | |
1623 (file-name-as-directory nnmail-tmp-directory) | |
1624 (file-name-nondirectory | |
1625 (concat (file-name-as-directory temp) "Incoming"))) | |
1626 (concat (file-name-as-directory temp) "Incoming"))))) | |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24600
diff
changeset
|
1627 (unless (file-exists-p (file-name-directory prefix)) |
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24600
diff
changeset
|
1628 (make-directory (file-name-directory prefix) t)) |
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
24600
diff
changeset
|
1629 (setq incoming (make-temp-file prefix))) |
17493 | 1630 (rename-file nnmail-crash-box incoming t) |
1631 (push incoming incomings)))) | |
1632 ;; If we did indeed read any incoming spools, we save all info. | |
1633 (when incomings | |
1634 (nnmail-save-active | |
1635 (nnmail-get-value "%s-group-alist" method) | |
1636 (nnmail-get-value "%s-active-file" method)) | |
1637 (when exit-func | |
1638 (funcall exit-func)) | |
1639 (run-hooks 'nnmail-read-incoming-hook) | |
1640 (nnheader-message 3 "%s: Reading incoming mail...done" method)) | |
1641 ;; Close the message-id cache. | |
1642 (nnmail-cache-close) | |
1643 ;; Allow the user to hook. | |
1644 (run-hooks 'nnmail-post-get-new-mail-hook) | |
1645 ;; Delete all the temporary files. | |
1646 (while incomings | |
1647 (setq incoming (pop incomings)) | |
1648 (and nnmail-delete-incoming | |
1649 (file-exists-p incoming) | |
1650 (file-writable-p incoming) | |
1651 (delete-file incoming)))))) | |
1652 | |
1653 (defun nnmail-expired-article-p (group time force &optional inhibit) | |
1654 "Say whether an article that is TIME old in GROUP should be expired." | |
1655 (if force | |
1656 t | |
1657 (let ((days (or (and nnmail-expiry-wait-function | |
1658 (funcall nnmail-expiry-wait-function group)) | |
1659 nnmail-expiry-wait))) | |
1660 (cond ((or (eq days 'never) | |
1661 (and (not force) | |
1662 inhibit)) | |
1663 ;; This isn't an expirable group. | |
1664 nil) | |
1665 ((eq days 'immediate) | |
1666 ;; We expire all articles on sight. | |
1667 t) | |
1668 ((equal time '(0 0)) | |
1669 ;; This is an ange-ftp group, and we don't have any dates. | |
1670 nil) | |
1671 ((numberp days) | |
1672 (setq days (nnmail-days-to-time days)) | |
1673 ;; Compare the time with the current time. | |
1674 (nnmail-time-less days (nnmail-time-since time))))))) | |
1675 | |
1676 (defvar nnmail-read-passwd nil) | |
1677 (defun nnmail-read-passwd (prompt &rest args) | |
1678 "Read a password using PROMPT. | |
1679 If ARGS, PROMPT is used as an argument to `format'." | |
1680 (let ((prompt | |
1681 (if args | |
1682 (apply 'format prompt args) | |
1683 prompt))) | |
1684 (unless nnmail-read-passwd | |
24600
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1685 (if (fboundp 'read-passwd) |
17493 | 1686 (setq nnmail-read-passwd 'read-passwd) |
24600
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1687 (if (load "passwd" t) |
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1688 (setq nnmail-read-passwd 'read-passwd) |
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1689 (unless (fboundp 'ange-ftp-read-passwd) |
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1690 (autoload 'ange-ftp-read-passwd "ange-ftp")) |
5e026e6efc73
(nnmail-read-passwd): Use read-passwd if that is defined.
Richard M. Stallman <rms@gnu.org>
parents:
24357
diff
changeset
|
1691 (setq nnmail-read-passwd 'ange-ftp-read-passwd)))) |
17493 | 1692 (funcall nnmail-read-passwd prompt))) |
1693 | |
1694 (defun nnmail-check-syntax () | |
1695 "Check (and modify) the syntax of the message in the current buffer." | |
1696 (save-restriction | |
1697 (message-narrow-to-head) | |
1698 (let ((case-fold-search t)) | |
1699 (unless (re-search-forward "^Message-ID[ \t]*:" nil t) | |
1700 (insert "Message-ID: " (nnmail-message-id) "\n"))))) | |
1701 | |
1702 (defun nnmail-write-region (start end filename &optional append visit lockname) | |
1703 "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
|
1704 (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
|
1705 (pathname-coding-system 'binary)) |
19593
6d421627bb8b
(nnmail-active-file-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19522
diff
changeset
|
1706 (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
|
1707 (set-file-modes filename nnmail-default-file-modes))) |
17493 | 1708 |
1709 ;;; | |
1710 ;;; Status functions | |
1711 ;;; | |
1712 | |
1713 (defun nnmail-replace-status (name value) | |
1714 "Make status NAME and VALUE part of the current status line." | |
1715 (save-restriction | |
1716 (message-narrow-to-head) | |
1717 (let ((status (nnmail-decode-status))) | |
1718 (setq status (delq (member name status) status)) | |
1719 (when value | |
1720 (push (cons name value) status)) | |
1721 (message-remove-header "status") | |
1722 (goto-char (point-max)) | |
1723 (insert "Status: " (nnmail-encode-status status) "\n")))) | |
1724 | |
1725 (defun nnmail-decode-status () | |
1726 "Return a status-value alist from STATUS." | |
1727 (goto-char (point-min)) | |
1728 (when (re-search-forward "^Status: " nil t) | |
1729 (let (name value status) | |
1730 (save-restriction | |
1731 ;; Narrow to the status. | |
1732 (narrow-to-region | |
1733 (point) | |
1734 (if (re-search-forward "^[^ \t]" nil t) | |
1735 (1- (point)) | |
1736 (point-max))) | |
1737 ;; Go through all elements and add them to the list. | |
1738 (goto-char (point-min)) | |
1739 (while (re-search-forward "[^ \t=]+" nil t) | |
1740 (setq name (match-string 0)) | |
1741 (if (not (= (following-char) ?=)) | |
1742 ;; Implied "yes". | |
1743 (setq value "yes") | |
1744 (forward-char 1) | |
1745 (if (not (= (following-char) ?\")) | |
1746 (if (not (looking-at "[^ \t]")) | |
1747 ;; Implied "no". | |
1748 (setq value "no") | |
1749 ;; Unquoted value. | |
1750 (setq value (match-string 0)) | |
1751 (goto-char (match-end 0))) | |
1752 ;; Quoted value. | |
1753 (setq value (read (current-buffer))))) | |
1754 (push (cons name value) status))) | |
1755 status))) | |
1756 | |
1757 (defun nnmail-encode-status (status) | |
1758 "Return a status string from STATUS." | |
1759 (mapconcat | |
1760 (lambda (elem) | |
1761 (concat | |
1762 (car elem) "=" | |
1763 (if (string-match "[ \t]" (cdr elem)) | |
1764 (prin1-to-string (cdr elem)) | |
1765 (cdr elem)))) | |
1766 status " ")) | |
1767 | |
1768 (defun nnmail-split-history () | |
1769 "Generate an overview of where the last mail split put articles." | |
1770 (interactive) | |
1771 (unless nnmail-split-history | |
1772 (error "No current split history")) | |
1773 (with-output-to-temp-buffer "*nnmail split history*" | |
1774 (let ((history nnmail-split-history) | |
1775 elem) | |
1776 (while (setq elem (pop history)) | |
1777 (princ (mapconcat (lambda (ga) | |
1778 (concat (car ga) ":" (int-to-string (cdr ga)))) | |
1779 elem | |
1780 ", ")) | |
1781 (princ "\n"))))) | |
1782 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1783 (defun nnmail-purge-split-history (group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1784 "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
|
1785 (let ((history nnmail-split-history)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1786 (while history |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1787 (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
|
1788 (car history))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1789 (pop history)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1790 (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
|
1791 |
17493 | 1792 (defun nnmail-new-mail-p (group) |
1793 "Say whether GROUP has new mail." | |
1794 (let ((his nnmail-split-history) | |
1795 found) | |
1796 (while his | |
1797 (when (assoc group (pop his)) | |
1798 (setq found t | |
1799 his nil))) | |
1800 found)) | |
1801 | |
1802 (eval-and-compile | |
1803 (autoload 'pop3-movemail "pop3")) | |
1804 | |
1805 (defun nnmail-pop3-movemail (inbox crashbox) | |
1806 "Function to move mail from INBOX on a pop3 server to file CRASHBOX." | |
1807 (let ((pop3-maildrop | |
1808 (substring inbox (match-end (string-match "^po:" inbox))))) | |
1809 (pop3-movemail crashbox))) | |
1810 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1811 (defun nnmail-within-headers-p () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1812 "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
|
1813 Doesn't change point." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1814 (let ((pos (point))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1815 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19988
diff
changeset
|
1816 (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
|
1817 (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
|
1818 |
17493 | 1819 (run-hooks 'nnmail-load-hook) |
1820 | |
1821 (provide 'nnmail) | |
1822 | |
1823 ;;; nnmail.el ends here |