* mml2015.el (mml2015-epg-sign): Ask user whether to skip or abort if
[gnus] / lisp / nnmail.el
1 ;;; nnmail.el --- mail support functions for the Gnus mail backends
2
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;;   2004, 2005, 2006 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news, mail
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)                         ; for macro gnus-kill-buffer, at least
33 (require 'nnheader)
34 (require 'message)
35 (require 'gnus-util)
36 (require 'mail-source)
37 (require 'mm-util)
38
39 (eval-and-compile
40   (autoload 'gnus-add-buffer "gnus")
41   (autoload 'gnus-kill-buffer "gnus"))
42
43 (defgroup nnmail nil
44   "Reading mail with Gnus."
45   :group 'gnus)
46
47 (defgroup nnmail-retrieve nil
48   "Retrieving new mail."
49   :group 'nnmail)
50
51 (defgroup nnmail-prepare nil
52   "Preparing (or mangling) new mail after retrieval."
53   :group 'nnmail)
54
55 (defgroup nnmail-duplicate nil
56   "Handling of duplicate mail messages."
57   :group 'nnmail)
58
59 (defgroup nnmail-split nil
60   "Organizing the incoming mail in folders."
61   :group 'nnmail)
62
63 (defgroup nnmail-files nil
64   "Mail files."
65   :group 'gnus-files
66   :group 'nnmail)
67
68 (defgroup nnmail-expire nil
69   "Expiring old mail."
70   :group 'nnmail)
71
72 (defgroup nnmail-procmail nil
73   "Interfacing with procmail and other mail agents."
74   :group 'nnmail)
75
76 (defgroup nnmail-various nil
77   "Various mail options."
78   :group 'nnmail)
79
80 (defcustom nnmail-split-methods '(("mail.misc" ""))
81   "*Incoming mail will be split according to this variable.
82
83 If you'd like, for instance, one mail group for mail from the
84 \"4ad-l\" mailing list, one group for junk mail and one for everything
85 else, you could do something like this:
86
87  (setq nnmail-split-methods
88        '((\"mail.4ad\" \"From:.*4ad\")
89          (\"mail.junk\" \"From:.*Lars\\\\|Subject:.*buy\")
90          (\"mail.misc\" \"\")))
91
92 As you can see, this variable is a list of lists, where the first
93 element in each \"rule\" is the name of the group (which, by the way,
94 does not have to be called anything beginning with \"mail\",
95 \"yonka.zow\" is a fine, fine name), and the second is a regexp that
96 nnmail will try to match on the header to find a fit.
97
98 The second element can also be a function.  In that case, it will be
99 called narrowed to the headers with the first element of the rule as
100 the argument.  It should return a non-nil value if it thinks that the
101 mail belongs in that group.
102
103 The last element should always have \"\" as the regexp.
104
105 This variable can also have a function as its value."
106   :group 'nnmail-split
107   :type '(choice (repeat :tag "Alist" (group (string :tag "Name")
108                                              (choice regexp function)))
109                  (function-item nnmail-split-fancy)
110                  (function :tag "Other")))
111
112 ;; Suggested by Erik Selberg <speed@cs.washington.edu>.
113 (defcustom nnmail-crosspost t
114   "If non-nil, do crossposting if several split methods match the mail.
115 If nil, the first match found will be used."
116   :group 'nnmail-split
117   :type 'boolean)
118
119 (defcustom nnmail-split-fancy-with-parent-ignore-groups nil
120   "Regexp that matches group names to be ignored when applying `nnmail-split-fancy-with-parent'.
121 This can also be a list of regexps."
122   :version "22.1"
123   :group 'nnmail-split
124   :type '(choice (const :tag "none" nil)
125                  (regexp :value ".*")
126                  (repeat :value (".*") regexp)))
127
128 (defcustom nnmail-cache-ignore-groups nil
129   "Regexp that matches group names to be ignored when inserting message ids into the cache (`nnmail-cache-insert').
130 This can also be a list of regexps."
131   :version "22.1"
132   :group 'nnmail-split
133   :type '(choice (const :tag "none" nil)
134                  (regexp :value ".*")
135                  (repeat :value (".*") regexp)))
136
137 ;; Added by gord@enci.ucalgary.ca (Gordon Matzigkeit).
138 (defcustom nnmail-keep-last-article nil
139   "If non-nil, nnmail will never delete/move a group's last article.
140 It can be marked expirable, so it will be deleted when it is no longer last.
141
142 You may need to set this variable if other programs are putting
143 new mail into folder numbers that Gnus has marked as expired."
144   :group 'nnmail-procmail
145   :group 'nnmail-various
146   :type 'boolean)
147
148 (defcustom nnmail-use-long-file-names nil
149   "If non-nil the mail backends will use long file and directory names.
150 If nil, groups like \"mail.misc\" will end up in directories like
151 \"mail/misc/\"."
152   :group 'nnmail-files
153   :type 'boolean)
154
155 (defcustom nnmail-default-file-modes 384
156   "Set the mode bits of all new mail files to this integer."
157   :group 'nnmail-files
158   :type 'integer)
159
160 (defcustom nnmail-expiry-wait 7
161   "*Expirable articles that are older than this will be expired.
162 This variable can either be a number (which will be interpreted as a
163 number of days) -- this doesn't have to be an integer.  This variable
164 can also be `immediate' and `never'."
165   :group 'nnmail-expire
166   :type '(choice (const immediate)
167                  (number :tag "days")
168                  (const never)))
169
170 (defcustom nnmail-expiry-wait-function nil
171   "Variable that holds function to specify how old articles should be before they are expired.
172 The function will be called with the name of the group that the expiry
173 is to be performed in, and it should return an integer that says how
174 many days an article can be stored before it is considered \"old\".
175 It can also return the values `never' and `immediate'.
176
177 Eg.:
178
179 \(setq nnmail-expiry-wait-function
180       (lambda (newsgroup)
181         (cond ((string-match \"private\" newsgroup) 31)
182               ((string-match \"junk\" newsgroup) 1)
183               ((string-match \"important\" newsgroup) 'never)
184               (t 7))))"
185   :group 'nnmail-expire
186   :type '(choice (const :tag "nnmail-expiry-wait" nil)
187                  (function :format "%v" nnmail-)))
188
189 (defcustom nnmail-expiry-target 'delete
190   "*Variable that says where expired messages should end up.
191 The default value is `delete' (which says to delete the messages),
192 but it can also be a string or a function.  If it is a string, expired
193 messages end up in that group.  If it is a function, the function is
194 called in a buffer narrowed to the message in question.  The function
195 receives one argument, the name of the group the message comes from.
196 The return value should be `delete' or a group name (a string)."
197   :version "21.1"
198   :group 'nnmail-expire
199   :type '(choice (const delete)
200                  (function :format "%v" nnmail-)
201                  string))
202
203 (defcustom nnmail-fancy-expiry-targets nil
204   "Determine expiry target based on articles using fancy techniques.
205
206 This is a list of (\"HEADER\" \"REGEXP\" \"TARGET\") entries.  If
207 `nnmail-expiry-target' is set to the function
208 `nnmail-fancy-expiry-target' and HEADER of the article matches REGEXP,
209 the message will be expired to a group determined by invoking
210 `format-time-string' with TARGET used as the format string and the
211 time extracted from the articles' Date header (if missing the current
212 time is used).
213
214 In the special cases that HEADER is the symbol `to-from', the regexp
215 will try to match against both the From and the To header.
216
217 Example:
218
219 \(setq nnmail-fancy-expiry-targets
220       '((to-from \"boss\" \"nnfolder:Work\")
221         (\"Subject\" \"IMPORTANT\" \"nnfolder:IMPORTANT.%Y.%b\")
222         (\"from\" \".*\" \"nnfolder:Archive-%Y\")))
223
224 In this case, articles containing the string \"boss\" in the To or the
225 From header will be expired to the group \"nnfolder:Work\";
226 articles containing the sting \"IMPORTANT\" in the Subject header will
227 be expired to the group \"nnfolder:IMPORTANT.YYYY.MMM\"; and
228 everything else will be expired to \"nnfolder:Archive-YYYY\"."
229   :version "22.1"
230   :group 'nnmail-expire
231   :type '(repeat (list (choice :tag "Match against"
232                                (string :tag "Header")
233                                (const to-from))
234                        regexp
235                        (string :tag "Target group format string"))))
236
237 (defcustom nnmail-cache-accepted-message-ids nil
238   "If non-nil, put Message-IDs of Gcc'd articles into the duplicate cache.
239 If non-nil, also update the cache when copy or move articles."
240   :group 'nnmail
241   :type 'boolean)
242
243 (defcustom nnmail-spool-file '((file))
244   "*Where the mail backends will look for incoming mail.
245 This variable is a list of mail source specifiers.
246 This variable is obsolete; `mail-sources' should be used instead."
247   :group 'nnmail-files
248   :type 'sexp)
249
250 (defcustom nnmail-resplit-incoming nil
251   "*If non-nil, re-split incoming procmail sorted mail."
252   :group 'nnmail-procmail
253   :type 'boolean)
254
255 (defcustom nnmail-scan-directory-mail-source-once nil
256   "*If non-nil, scan all incoming procmail sorted mails once.
257 It scans low-level sorted spools even when not required."
258   :version "21.1"
259   :group 'nnmail-procmail
260   :type 'boolean)
261
262 (defcustom nnmail-delete-file-function 'delete-file
263   "Function called to delete files in some mail backends."
264   :group 'nnmail-files
265   :type 'function)
266
267 (defcustom nnmail-crosspost-link-function
268   (if (string-match "windows-nt\\|emx" (symbol-name system-type))
269       'copy-file
270     'add-name-to-file)
271   "*Function called to create a copy of a file.
272 This is `add-name-to-file' by default, which means that crossposts
273 will use hard links.  If your file system doesn't allow hard
274 links, you could set this variable to `copy-file' instead."
275   :group 'nnmail-files
276   :type '(radio (function-item add-name-to-file)
277                 (function-item copy-file)
278                 (function :tag "Other")))
279
280 (defcustom nnmail-read-incoming-hook
281   (if (eq system-type 'windows-nt)
282       '(nnheader-ms-strip-cr)
283     nil)
284   "*Hook that will be run after the incoming mail has been transferred.
285 The incoming mail is moved from the specified spool file (which normally is
286 something like \"/usr/spool/mail/$user\") to the user's home
287 directory.  This hook is called after the incoming mail box has been
288 emptied, and can be used to call any mail box programs you have
289 running (\"xwatch\", etc.)
290
291 Eg.
292
293 \(add-hook 'nnmail-read-incoming-hook
294           (lambda ()
295             (call-process \"/local/bin/mailsend\" nil nil nil
296                           \"read\" nnmail-spool-file)))
297
298 If you have xwatch running, this will alert it that mail has been
299 read.
300
301 If you use `display-time', you could use something like this:
302
303 \(add-hook 'nnmail-read-incoming-hook
304           (lambda ()
305             ;; Update the displayed time, since that will clear out
306             ;; the flag that says you have mail.
307             (when (eq (process-status \"display-time\") 'run)
308               (display-time-filter display-time-process \"\"))))"
309   :group 'nnmail-prepare
310   :type 'hook)
311
312 (defcustom nnmail-prepare-incoming-hook nil
313   "Hook called before treating incoming mail.
314 The hook is run in a buffer with all the new, incoming mail."
315   :group 'nnmail-prepare
316   :type 'hook)
317
318 (defcustom nnmail-prepare-incoming-header-hook nil
319   "Hook called narrowed to the headers of each message.
320 This can be used to remove excessive spaces (and stuff like
321 that) from the headers before splitting and saving the messages."
322   :group 'nnmail-prepare
323   :type 'hook)
324
325 (defcustom nnmail-prepare-incoming-message-hook nil
326   "Hook called narrowed to each message."
327   :group 'nnmail-prepare
328   :type 'hook)
329
330 (defcustom nnmail-list-identifiers nil
331   "Regexp that matches list identifiers to be removed.
332 This can also be a list of regexps."
333   :group 'nnmail-prepare
334   :type '(choice (const :tag "none" nil)
335                  (regexp :value ".*")
336                  (repeat :value (".*") regexp)))
337
338 (defcustom nnmail-pre-get-new-mail-hook nil
339   "Hook called just before starting to handle new incoming mail."
340   :group 'nnmail-retrieve
341   :type 'hook)
342
343 (defcustom nnmail-post-get-new-mail-hook nil
344   "Hook called just after finishing handling new incoming mail."
345   :group 'nnmail-retrieve
346   :type 'hook)
347
348 (defcustom nnmail-split-hook nil
349   "Hook called before deciding where to split an article.
350 The functions in this hook are free to modify the buffer
351 contents in any way they choose -- the buffer contents are
352 discarded after running the split process."
353   :group 'nnmail-split
354   :type 'hook)
355
356 (defcustom nnmail-spool-hook nil
357   "*A hook called when a new article is spooled."
358   :version "22.1"
359   :group 'nnmail
360   :type 'hook)
361
362 (defcustom nnmail-large-newsgroup 50
363   "*The number of articles which indicates a large newsgroup or nil.
364 If the number of articles is greater than the value, verbose
365 messages will be shown to indicate the current status."
366   :group 'nnmail-various
367   :type '(choice (const :tag "infinite" nil)
368                  (number :tag "count")))
369
370 (define-widget 'nnmail-lazy 'default
371   "Base widget for recursive datastructures.
372
373 This is copy of the `lazy' widget in Emacs 22.1 provided for compatibility."
374   :format "%{%t%}: %v"
375   :convert-widget 'widget-value-convert-widget
376   :value-create (lambda (widget)
377                   (let ((value (widget-get widget :value))
378                         (type (widget-get widget :type)))
379                     (widget-put widget :children
380                                 (list (widget-create-child-value
381                                        widget (widget-convert type) value)))))
382   :value-delete 'widget-children-value-delete
383   :value-get (lambda (widget)
384                (widget-value (car (widget-get widget :children))))
385   :value-inline (lambda (widget)
386                   (widget-apply (car (widget-get widget :children))
387                                 :value-inline))
388   :default-get (lambda (widget)
389                  (widget-default-get
390                   (widget-convert (widget-get widget :type))))
391   :match (lambda (widget value)
392            (widget-apply (widget-convert (widget-get widget :type))
393                          :match value))
394   :validate (lambda (widget)
395               (widget-apply (car (widget-get widget :children)) :validate)))
396
397 (define-widget 'nnmail-split-fancy 'nnmail-lazy
398   "Widget for customizing splits in the variable of the same name."
399   :tag "Split"
400   :type '(menu-choice :value (any ".*value.*" "misc")
401                       :tag "Type"
402                       (string :tag "Destination")
403                       (list :tag "Use first match (|)" :value (|)
404                             (const :format "" |)
405                             (editable-list :inline t nnmail-split-fancy))
406                       (list :tag "Use all matches (&)" :value (&)
407                             (const :format "" &)
408                             (editable-list :inline t nnmail-split-fancy))
409                       (list :tag "Function with fixed arguments (:)"
410                             :value (:)
411                             (const :format "" :value :)
412                             function
413                             (editable-list :inline t (sexp :tag "Arg"))
414                             )
415                       (list :tag "Function with split arguments (!)"
416                             :value (!)
417                             (const :format "" !)
418                             function
419                             (editable-list :inline t nnmail-split-fancy))
420                       (list :tag "Field match"
421                             (choice :tag "Field"
422                                     regexp symbol)
423                             (choice :tag "Match"
424                                     regexp
425                                     (symbol :value mail))
426                             (repeat :inline t
427                                     :tag "Restrictions"
428                                     (group :inline t
429                                            (const :format "" -)
430                                            regexp))
431                             nnmail-split-fancy)
432                       (const :tag "Junk (delete mail)" junk)))
433
434 (defcustom nnmail-split-fancy "mail.misc"
435   "Incoming mail can be split according to this fancy variable.
436 To enable this, set `nnmail-split-methods' to `nnmail-split-fancy'.
437
438 The format of this variable is SPLIT, where SPLIT can be one of
439 the following:
440
441 GROUP: Mail will be stored in GROUP (a string).
442
443 \(FIELD VALUE [- RESTRICT [- RESTRICT [...]]] SPLIT): If the message
444   field FIELD (a regexp) contains VALUE (a regexp), store the messages
445   as specified by SPLIT.  If RESTRICT (a regexp) matches some string
446   after FIELD and before the end of the matched VALUE, return nil,
447   otherwise process SPLIT.  Multiple RESTRICTs add up, further
448   restricting the possibility of processing SPLIT.
449
450 \(| SPLIT...): Process each SPLIT expression until one of them matches.
451   A SPLIT expression is said to match if it will cause the mail
452   message to be stored in one or more groups.
453
454 \(& SPLIT...): Process each SPLIT expression.
455
456 \(: FUNCTION optional args): Call FUNCTION with the optional args, in
457   the buffer containing the message headers.  The return value FUNCTION
458   should be a split, which is then recursively processed.
459
460 \(! FUNCTION SPLIT): Call FUNCTION with the result of SPLIT.  The
461   return value FUNCTION should be a split, which is then recursively
462   processed.
463
464 junk: Mail will be deleted.  Use with care!  Do not submerge in water!
465   Example:
466   (setq nnmail-split-fancy
467         '(| (\"Subject\" \"MAKE MONEY FAST\" junk)
468             ...other.rules.omitted...))
469
470 FIELD must match a complete field name.  VALUE must match a complete
471 word according to the `nnmail-split-fancy-syntax-table' syntax table.
472 You can use \".*\" in the regexps to match partial field names or words.
473
474 FIELD and VALUE can also be Lisp symbols, in that case they are expanded
475 as specified in `nnmail-split-abbrev-alist'.
476
477 GROUP can contain \\& and \\N which will substitute from matching
478 \\(\\) patterns in the previous VALUE.
479
480 Example:
481
482 \(setq nnmail-split-methods 'nnmail-split-fancy
483       nnmail-split-fancy
484       ;; Messages from the mailer daemon are not crossposted to any of
485       ;; the ordinary groups.  Warnings are put in a separate group
486       ;; from real errors.
487       '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
488                           \"mail.misc\"))
489           ;; Non-error messages are crossposted to all relevant
490           ;; groups, but we don't crosspost between the group for the
491           ;; (ding) list and the group for other (ding) related mail.
492           (& (| (any \"ding@ifi\\\\.uio\\\\.no\" \"ding.list\")
493                 (\"subject\" \"ding\" \"ding.misc\"))
494              ;; Other mailing lists...
495              (any \"procmail@informatik\\\\.rwth-aachen\\\\.de\" \"procmail.list\")
496              (any \"SmartList@informatik\\\\.rwth-aachen\\\\.de\" \"SmartList.list\")
497              ;; Both lists below have the same suffix, so prevent
498              ;; cross-posting to mkpkg.list of messages posted only to
499              ;; the bugs- list, but allow cross-posting when the
500              ;; message was really cross-posted.
501              (any \"bugs-mypackage@somewhere\" \"mypkg.bugs\")
502              (any \"mypackage@somewhere\" - \"bugs-mypackage\" \"mypkg.list\")
503              ;;
504              ;; People...
505              (any \"larsi@ifi\\\\.uio\\\\.no\" \"people.Lars Magne Ingebrigtsen\"))
506           ;; Unmatched mail goes to the catch all group.
507           \"misc.misc\"))"
508   :group 'nnmail-split
509   :type 'nnmail-split-fancy)
510
511 (defcustom nnmail-split-abbrev-alist
512   '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")
513     (mail . "mailer-daemon\\|postmaster\\|uucp")
514     (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc")
515     (from . "from\\|sender\\|resent-from")
516     (nato . "to\\|cc\\|resent-to\\|resent-cc")
517     (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc"))
518   "*Alist of abbreviations allowed in `nnmail-split-fancy'."
519   :group 'nnmail-split
520   :type '(repeat (cons :format "%v" symbol regexp)))
521
522 (defcustom nnmail-message-id-cache-length 1000
523   "*The approximate number of Message-IDs nnmail will keep in its cache.
524 If this variable is nil, no checking on duplicate messages will be
525 performed."
526   :group 'nnmail-duplicate
527   :type '(choice (const :tag "disable" nil)
528                  (integer :format "%v")))
529
530 (defcustom nnmail-message-id-cache-file "~/.nnmail-cache"
531   "*The file name of the nnmail Message-ID cache."
532   :group 'nnmail-duplicate
533   :group 'nnmail-files
534   :type 'file)
535
536 (defcustom nnmail-treat-duplicates 'warn
537   "*If non-nil, nnmail keep a cache of Message-IDs to discover mail duplicates.
538 Three values are valid: nil, which means that nnmail is not to keep a
539 Message-ID cache; `warn', which means that nnmail should insert extra
540 headers to warn the user about the duplication (this is the default);
541 and `delete', which means that nnmail will delete duplicated mails.
542
543 This variable can also be a function.  It will be called from a buffer
544 narrowed to the article in question with the Message-ID as a
545 parameter.  It should return nil, `warn' or `delete'."
546   :group 'nnmail-duplicate
547   :type '(choice (const :tag "off" nil)
548                  (const warn)
549                  (const delete)))
550
551 (defcustom nnmail-extra-headers '(To Newsgroups)
552   "*Extra headers to parse."
553   :version "21.1"
554   :group 'nnmail
555   :type '(repeat symbol))
556
557 (defcustom nnmail-split-header-length-limit 2048
558   "Header lines longer than this limit are excluded from the split function."
559   :version "21.1"
560   :group 'nnmail
561   :type 'integer)
562
563 (defcustom nnmail-mail-splitting-charset nil
564   "Default charset to be used when splitting incoming mail."
565   :version "22.1"
566   :group 'nnmail
567   :type 'symbol)
568
569 (defcustom nnmail-mail-splitting-decodes nil
570   "Whether the nnmail splitting functionality should MIME decode headers."
571   :version "22.1"
572   :group 'nnmail
573   :type 'boolean)
574
575 (defcustom nnmail-split-fancy-match-partial-words nil
576   "Whether to match partial words when fancy splitting.
577 Normally, regexes given in `nnmail-split-fancy' are implicitly surrounded
578 by \"\\=\\<...\\>\".  If this variable is true, they are not implicitly\
579  surrounded
580 by anything."
581   :version "22.1"
582   :group 'nnmail
583   :type 'boolean)
584
585 (defcustom nnmail-split-lowercase-expanded t
586   "Whether to lowercase expanded entries (i.e. \\N) when splitting mails.
587 This avoids the creation of multiple groups when users send to an address
588 using different case (i.e. mailing-list@domain vs Mailing-List@Domain)."
589   :version "22.1"
590   :group 'nnmail
591   :type 'boolean)
592
593 ;;; Internal variables.
594
595 (defvar nnmail-article-buffer " *nnmail incoming*"
596   "The buffer used for splitting incoming mails.")
597
598 (defvar nnmail-split-history nil
599   "List of group/article elements that say where the previous split put messages.")
600
601 (defvar nnmail-split-fancy-syntax-table
602   (let ((table (make-syntax-table)))
603     ;; support the %-hack
604     (modify-syntax-entry ?\% "." table)
605     table)
606   "Syntax table used by `nnmail-split-fancy'.")
607
608 (defvar nnmail-prepare-save-mail-hook nil
609   "Hook called before saving mail.")
610
611 (defvar nnmail-split-tracing nil)
612 (defvar nnmail-split-trace nil)
613
614 \f
615
616 (defun nnmail-request-post (&optional server)
617   (mail-send-and-exit nil))
618
619 (defvar nnmail-file-coding-system 'raw-text
620   "Coding system used in nnmail.")
621
622 (defvar nnmail-incoming-coding-system
623   mm-text-coding-system
624   "Coding system used in reading inbox")
625
626 (defvar nnmail-pathname-coding-system nil
627   "*Coding system for file name.")
628
629 (defun nnmail-find-file (file)
630   "Insert FILE in server buffer safely."
631   (set-buffer nntp-server-buffer)
632   (delete-region (point-min) (point-max))
633   (let ((format-alist nil)
634         (after-insert-file-functions nil))
635     (condition-case ()
636         (let ((coding-system-for-read nnmail-file-coding-system)
637               (auto-mode-alist (mm-auto-mode-alist))
638               (file-name-coding-system nnmail-pathname-coding-system))
639           (insert-file-contents file)
640           t)
641       (file-error nil))))
642
643 (defun nnmail-group-pathname (group dir &optional file)
644   "Make file name for GROUP."
645   (concat
646    (let ((dir (file-name-as-directory (expand-file-name dir))))
647      (setq group (nnheader-replace-duplicate-chars-in-string
648                   (nnheader-replace-chars-in-string group ?/ ?_)
649                   ?. ?_))
650      (setq group (nnheader-translate-file-chars group))
651      ;; If this directory exists, we use it directly.
652      (file-name-as-directory
653       (if (or nnmail-use-long-file-names
654               (file-directory-p (concat dir group)))
655           (expand-file-name group dir)
656         ;; If not, we translate dots into slashes.
657         (expand-file-name
658          (mm-encode-coding-string
659           (nnheader-replace-chars-in-string group ?. ?/)
660           nnmail-pathname-coding-system)
661          dir))))
662    (or file "")))
663
664 (defun nnmail-get-active ()
665   "Returns an assoc of group names and active ranges.
666 nn*-request-list should have been called before calling this function."
667   ;; Go through all groups from the active list.
668   (save-excursion
669     (set-buffer nntp-server-buffer)
670     (nnmail-parse-active)))
671
672 (defun nnmail-parse-active ()
673   "Parse the active file in the current buffer and return an alist."
674   (goto-char (point-min))
675   (unless (re-search-forward "[\\\"]" nil t)
676     (goto-char (point-max))
677     (while (re-search-backward "[][';?()#]" nil t)
678       (insert ?\\)))
679   (goto-char (point-min))
680   (let ((buffer (current-buffer))
681         group-assoc group max min)
682     (while (not (eobp))
683       (condition-case err
684           (progn
685     &nb