1 ;;; nnmail.el --- mail support functions for the Gnus mail backends
2 ;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news, mail
7 ;; This file is part of GNU Emacs.
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)
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.
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.
28 (eval-when-compile (require 'cl))
34 (require 'mail-source)
38 (autoload 'gnus-error "gnus-util")
39 (autoload 'gnus-buffer-live-p "gnus-util"))
42 "Reading mail with Gnus."
45 (defgroup nnmail-retrieve nil
46 "Retrieving new mail."
49 (defgroup nnmail-prepare nil
50 "Preparing (or mangling) new mail after retrival."
53 (defgroup nnmail-duplicate nil
54 "Handling of duplicate mail messages."
57 (defgroup nnmail-split nil
58 "Organizing the incomming mail in folders."
61 (defgroup nnmail-files nil
66 (defgroup nnmail-expire nil
70 (defgroup nnmail-procmail nil
71 "Interfacing with procmail and other mail agents."
74 (defgroup nnmail-various nil
75 "Various mail options."
78 (defcustom nnmail-split-methods
80 "*Incoming mail will be split according to this variable.
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:
86 (setq nnmail-split-methods
87 '((\"mail.4ad\" \"From:.*4ad\")
88 (\"mail.junk\" \"From:.*Lars\\\\|Subject:.*buy\")
89 (\"mail.misc\" \"\")))
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.
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.
102 The last element should always have \"\" as the regexp.
104 This variable can also have a function as its value."
106 :type '(choice (repeat :tag "Alist" (group (string :tag "Name") regexp))
107 (function-item nnmail-split-fancy)
108 (function :tag "Other")))
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."
117 ;; Added by gord@enci.ucalgary.ca (Gordon Matzigkeit).
118 (defcustom nnmail-keep-last-article nil
119 "If non-nil, nnmail will never delete/move a group's last article.
120 It can be marked expirable, so it will be deleted when it is no longer last.
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
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
135 (defcustom nnmail-default-file-modes 384
136 "Set the mode bits of all new mail files to this integer."
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")
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'.
159 \(setq nnmail-expiry-wait-function
161 (cond ((string-match \"private\" newsgroup) 31)
162 ((string-match \"junk\" newsgroup) 1)
163 ((string-match \"important\" newsgroup) 'never)
165 :group 'nnmail-expire
166 :type '(choice (const :tag "nnmail-expiry-wait" nil)
167 (function :format "%v" nnmail-)))
169 (defcustom nnmail-cache-accepted-message-ids nil
170 "If non-nil, put Message-IDs of Gcc'd articles into the duplicate cache."
174 (defcustom nnmail-spool-file '((file))
175 "*Where the mail backends will look for incoming mail.
176 This variable is a list of mail source specifiers.
177 This variable is obsolete; `mail-sources' should be used instead."
181 (defcustom nnmail-resplit-incoming nil
182 "*If non-nil, re-split incoming procmail sorted mail."
183 :group 'nnmail-procmail
186 (defcustom nnmail-delete-file-function 'delete-file
187 "Function called to delete files in some mail backends."
191 (defcustom nnmail-crosspost-link-function
192 (if (string-match "windows-nt\\|emx" (symbol-name system-type))
195 "*Function called to create a copy of a file.
196 This is `add-name-to-file' by default, which means that crossposts
197 will use hard links. If your file system doesn't allow hard
198 links, you could set this variable to `copy-file' instead."
200 :type '(radio (function-item add-name-to-file)
201 (function-item copy-file)
202 (function :tag "Other")))
204 (defcustom nnmail-read-incoming-hook
205 (if (eq system-type 'windows-nt)
206 '(nnheader-ms-strip-cr)
208 "*Hook that will be run after the incoming mail has been transferred.
209 The incoming mail is moved from `nnmail-spool-file' (which normally is
210 something like \"/usr/spool/mail/$user\") to the user's home
211 directory. This hook is called after the incoming mail box has been
212 emptied, and can be used to call any mail box programs you have
213 running (\"xwatch\", etc.)
217 \(add-hook 'nnmail-read-incoming-hook
219 (start-process \"mailsend\" nil
220 \"/local/bin/mailsend\" \"read\" \"mbox\")))
222 If you have xwatch running, this will alert it that mail has been
225 If you use `display-time', you could use something like this:
227 \(add-hook 'nnmail-read-incoming-hook
229 ;; Update the displayed time, since that will clear out
230 ;; the flag that says you have mail.
231 (when (eq (process-status \"display-time\") 'run)
232 (display-time-filter display-time-process \"\"))))"
233 :group 'nnmail-prepare
236 (defcustom nnmail-prepare-incoming-hook nil
237 "Hook called before treating incoming mail.
238 The hook is run in a buffer with all the new, incoming mail."
239 :group 'nnmail-prepare
242 (defcustom nnmail-prepare-incoming-header-hook nil
243 "Hook called narrowed to the headers of each message.
244 This can be used to remove excessive spaces (and stuff like
245 that) from the headers before splitting and saving the messages."
246 :group 'nnmail-prepare
249 (defcustom nnmail-prepare-incoming-message-hook nil
250 "Hook called narrowed to each message."
251 :group 'nnmail-prepare
254 (defcustom nnmail-list-identifiers nil
255 "Regexp that matches list identifiers to be removed.
256 This can also be a list of regexps."
257 :group 'nnmail-prepare
258 :type '(choice (const :tag "none" nil)
260 (repeat :value (".*") regexp)))
262 (defcustom nnmail-pre-get-new-mail-hook nil
263 "Hook called just before starting to handle new incoming mail."
264 :group 'nnmail-retrieve
267 (defcustom nnmail-post-get-new-mail-hook nil
268 "Hook called just after finishing handling new incoming mail."
269 :group 'nnmail-retrieve
272 (defcustom nnmail-split-hook nil
273 "Hook called before deciding where to split an article.
274 The functions in this hook are free to modify the buffer
275 contents in any way they choose -- the buffer contents are
276 discarded after running the split process."
280 (defcustom nnmail-large-newsgroup 50
281 "*The number of the articles which indicates a large newsgroup.
282 If the number of the articles is greater than the value, verbose
283 messages will be shown to indicate the current status."
284 :group 'nnmail-various
287 (defcustom nnmail-split-fancy "mail.misc"
288 "Incoming mail can be split according to this fancy variable.
289 To enable this, set `nnmail-split-methods' to `nnmail-split-fancy'.
291 The format of this variable is SPLIT, where SPLIT can be one of
294 GROUP: Mail will be stored in GROUP (a string).
296 \(FIELD VALUE SPLIT): If the message field FIELD (a regexp) contains
297 VALUE (a regexp), store the messages as specified by SPLIT.
299 \(| SPLIT...): Process each SPLIT expression until one of them matches.
300 A SPLIT expression is said to match if it will cause the mail
301 message to be stored in one or more groups.
303 \(& SPLIT...): Process each SPLIT expression.
305 \(: FUNCTION optional args): Call FUNCTION with the optional args, in
306 the buffer containing the message headers. The return value FUNCTION
307 should be a split, which is then recursively processed.
309 FIELD must match a complete field name. VALUE must match a complete
310 word according to the `nnmail-split-fancy-syntax-table' syntax table.
311 You can use \".*\" in the regexps to match partial field names or words.
313 FIELD and VALUE can also be lisp symbols, in that case they are expanded
314 as specified in `nnmail-split-abbrev-alist'.
316 GROUP can contain \\& and \\N which will substitute from matching
317 \\(\\) patterns in the previous VALUE.
321 \(setq nnmail-split-methods 'nnmail-split-fancy
323 ;; Messages from the mailer daemon are not crossposted to any of
324 ;; the ordinary groups. Warnings are put in a separate group
326 '(| (\"from\" mail (| (\"subject\" \"warn.*\" \"mail.warning\")
328 ;; Non-error messages are crossposted to all relevant
329 ;; groups, but we don't crosspost between the group for the
330 ;; (ding) list and the group for other (ding) related mail.
331 (& (| (any \"ding@ifi\\\\.uio\\\\.no\" \"ding.list\")
332 (\"subject\" \"ding\" \"ding.misc\"))
333 ;; Other mailing lists...
334 (any \"procmail@informatik\\\\.rwth-aachen\\\\.de\" \"procmail.list\")
335 (any \"SmartList@informatik\\\\.rwth-aachen\\\\.de\" \"SmartList.list\")
337 (any \"larsi@ifi\\\\.uio\\\\.no\" \"people.Lars Magne Ingebrigtsen\"))
338 ;; Unmatched mail goes to the catch all group.
344 (defcustom nnmail-split-abbrev-alist
345 '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")
346 (mail . "mailer-daemon\\|postmaster\\|uucp")
347 (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc")
348 (from . "from\\|sender\\|resent-from")
349 (nato . "to\\|cc\\|resent-to\\|resent-cc")
350 (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc"))
351 "*Alist of abbreviations allowed in `nnmail-split-fancy'."
353 :type '(repeat (cons :format "%v" symbol regexp)))
355 (defcustom nnmail-message-id-cache-length 1000
356 "*The approximate number of Message-IDs nnmail will keep in its cache.
357 If this variable is nil, no checking on duplicate messages will be
359 :group 'nnmail-duplicate
360 :type '(choice (const :tag "disable" nil)
361 (integer :format "%v")))
363 (defcustom nnmail-message-id-cache-file "~/.nnmail-cache"
364 "*The file name of the nnmail Message-ID cache."
365 :group 'nnmail-duplicate
369 (defcustom nnmail-treat-duplicates 'warn
370 "*If non-nil, nnmail keep a cache of Message-IDs to discover mail duplicates.
371 Three values are valid: nil, which means that nnmail is not to keep a
372 Message-ID cache; `warn', which means that nnmail should insert extra
373 headers to warn the user about the duplication (this is the default);
374 and `delete', which means that nnmail will delete duplicated mails.
376 This variable can also be a function. It will be called from a buffer
377 narrowed to the article in question with the Message-ID as a
378 parameter. It should return nil, `warn' or `delete'."
379 :group 'nnmail-duplicate
380 :type '(choice (const :tag "off" nil)
384 (defcustom nnmail-extra-headers nil
385 "*Extra headers to parse."
387 :type '(repeat symbol))
389 (defcustom nnmail-split-header-length-limit 512
390 "Header lines longer than this limit are excluded from the split function."
394 ;;; Internal variables.
396 (defvar nnmail-split-history nil
397 "List of group/article elements that say where the previous split put messages.")
399 (defvar nnmail-split-fancy-syntax-table nil
400 "Syntax table used by `nnmail-split-fancy'.")
401 (unless (syntax-table-p nnmail-split-fancy-syntax-table)
402 (setq nnmail-split-fancy-syntax-table
403 (copy-syntax-table (standard-syntax-table)))
404 ;; support the %-hack
405 (modify-syntax-entry ?\% "." nnmail-split-fancy-syntax-table))
407 (defvar nnmail-prepare-save-mail-hook nil
408 "Hook called before saving mail.")
410 (defvar nnmail-split-tracing nil)
411 (defvar nnmail-split-trace nil)
415 (defconst nnmail-version "nnmail 1.0"
420 (defun nnmail-request-post (&optional server)
421 (mail-send-and-exit nil))
423 (defvar nnmail-file-coding-system 'raw-text
424 "Coding system used in nnmail.")
426 (defvar nnmail-incoming-coding-system
427 mm-text-coding-system
428 "Coding system used in reading inbox")
430 (defvar nnmail-pathname-coding-system 'binary
431 "*Coding system for pathname.")
433 (defun nnmail-find-file (file)
434 "Insert FILE in server buffer safely."
435 (set-buffer nntp-server-buffer)
436 (delete-region (point-min) (point-max))
437 (let ((format-alist nil)
438 (after-insert-file-functions nil))
440 (let ((coding-system-for-read nnmail-file-coding-system)
441 (auto-mode-alist (nnheader-auto-mode-alist))
442 (pathname-coding-system nnmail-pathname-coding-system))
443 (insert-file-contents file)
447 (defun nnmail-group-pathname (group dir &optional file)
448 "Make pathname for GROUP."
450 (let ((dir (file-name-as-directory (expand-file-name dir))))
451 (setq group (nnheader-translate-file-chars group))
452 ;; If this directory exists, we use it directly.
453 (if (or nnmail-use-long-file-names
454 (file-directory-p (concat dir group)))
455 (concat dir group "/")
456 ;; If not, we translate dots into slashes.
458 (mm-encode-coding-string
459 (nnheader-replace-chars-in-string group ?. ?/)
460 nnmail-pathname-coding-system)
464 (defun nnmail-get-active ()
465 "Returns an assoc of group names and active ranges.
466 nn*-request-list should have been called before calling this function."
468 ;; Go through all groups from the active list.
470 (set-buffer nntp-server-buffer)
471 (goto-char (point-min))
472 (while (re-search-forward
473 "^\\([^ \t]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)" nil t)
474 ;; We create an alist with `(GROUP (LOW . HIGH))' elements.
475 (push (list (match-string 1)
476 (cons (string-to-int (match-string 3))
477 (string-to-int (match-string 2))))
481 (defvar nnmail-active-file-coding-system 'raw-text
482 "*Coding system for active file.")
484 (defun nnmail-save-active (group-assoc file-name)
485 "Save GROUP-ASSOC in ACTIVE-FILE."
486 (let ((coding-system-for-write nnmail-active-file-coding-system))
488 (with-temp-file file-name
489 (nnmail-generate-active group-assoc)))))
491 (defun nnmail-generate-active (alist)
492 "Generate an active file from group-alist ALIST."
495 (while (setq group (pop alist))
496 (insert (format "%s %d %d y\n" (car group) (cdadr group)
499 (defun nnmail-get-split-group (file source)
500 "Find out whether this FILE is to be split into GROUP only.
501 If SOURCE is a directory spec, try to return the group name component."
502 (if (eq (car source) 'directory)
503 (let ((file (file-name-nondirectory file)))
504 (mail-source-bind (directory source)
505 (if (string-match (concat (regexp-quote suffix) "$") file)
506 (substring file 0 (match-beginning 0))
510 (defun nnmail-process-babyl-mail-format (func artnum-func)
511 (let ((case-fold-search t)
513 start message-id content-length do-search end)
515 (goto-char (point-min))
517 "
\f\n0, *unseen,+\n\\(\\*\\*\\* EOOH \\*\\*\\*\n\\)?" nil t)
518 (goto-char (match-end 0))
519 (delete-region (match-beginning 0) (match-end 0))
523 ;; Skip all the headers in case there are more "From "s...
524 (or (search-forward "\n\n" nil t)
525 (search-forward-regexp "^[^:]*\\( .*\\|\\)$" nil t)
526 (search-forward "
\1f\f"))
528 ;; Unquote the ">From " line, if any.
529 (goto-char (point-min))
530 (when (looking-at ">From ")
531 (replace-match "X-From-Line: ") )
532 (run-hooks 'nnmail-prepare-incoming-header-hook)
533 (goto-char (point-max))
534 ;; Find the Message-ID header.
536 (if (re-search-backward
537 "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]*>\\)" nil t)
538 (setq message-id (buffer-substring (match-beginning 1)
540 ;; There is no Message-ID here, so we create one.
542 (when (re-search-backward "^Message-ID[ \t]*:" nil t)
544 (insert "Original-")))
546 (insert "Message-ID: " (setq message-id (nnmail-message-id))
548 ;; Look for a Content-Length header.
549 (if (not (save-excursion
550 (and (re-search-backward
551 "^Content-Length:[ \t]*\\([0-9]+\\)" start t)
552 (setq content-length (string-to-int
556 ;; We destroy the header, since none of
557 ;; the backends ever use it, and we do not
558 ;; want to confuse other mailers by having
559 ;; a (possibly) faulty header.
560 (progn (insert "X-") t))))
563 (if (or (= (+ (point) content-length) (point-max))
565 (goto-char (+ (point) content-length))
568 (goto-char (+ (point) content-length))
569 (setq do-search nil))
572 ;; Go to the beginning of the next article - or to the end
575 (if (re-search-forward "^
\1f" nil t)
576 (goto-char (match-beginning 0))
577 (goto-char (1- (point-max)))))
578 (delete-char 1) ; delete ^_
581 (narrow-to-region start (point))
582 (goto-char (point-min))
583 (nnmail-check-duplication message-id func artnum-func)
585 (setq end (point-max))))
589 (defsubst nnmail-search-unix-mail-delim ()
590 "Put point at the beginning of the next Unix mbox message."
591 ;; Algorithm used to find the the next article in the
592 ;; brain-dead Unix mbox format:
594 ;; 1) Search for "^From ".
595 ;; 2) If we find it, then see whether the previous
596 ;; line is blank and the next line looks like a header.
597 ;; Then it's possible that this is a mail delim, and we use it.
598 (let ((case-fold-search nil)
601 (if (not (re-search-forward "^From " nil t))
605 (when (and (or (bobp)
608 (eq (char-after) ?\n)))
611 (while (looking-at ">From \\|From ")
613 (looking-at "[^ \n\t:]+[ \n\t]*:")))
614 (setq found 'yes)))))
618 (defun nnmail-search-unix-mail-delim-backward ()
619 "Put point at the beginning of the current Unix mbox message."
620 ;; Algorithm used to find the the next article in the
621 ;; brain-dead Unix mbox format:
623 ;; 1) Search for "^From ".
624 ;; 2) If we find it, then see whether the previous
625 ;; line is blank and the next line looks like a header.
626 ;; Then it's possible that this is a mail delim, and we use it.
627 (let ((case-fold-search nil)
630 (if (not (re-search-backward "^From " nil t))
634 (when (and (or (bobp)
637 (eq (char-after) ?\n)))
640 (while (looking-at ">From \\|From ")
642 (looking-at "[^ \n\t:]+[ \n\t]*:")))
643 (setq found 'yes)))))
647 (defun nnmail-process-unix-mail-format (func artnum-func)
648 (let ((case-fold-search t)
650 start message-id content-length end skip head-end)
651 (goto-char (point-min))
652 (if (not (and (re-search-forward "^From " nil t)
653 (goto-char (match-beginning 0))))
654 ;; Possibly wrong format?
655 (error "Error, unknown mail format! (Possibly corrupted.)")
656 ;; Carry on until the bitter end.
660 ;; Find the end of the head.
663 (if (search-forward "\n\n" nil t)
665 ;; This will never happen, but just to be on the safe side --
666 ;; if there is no head-body delimiter, we search a bit manually.
667 (while (and (looking-at "From \\|[^ \t]+:")
671 ;; Find the Message-ID header.
672 (goto-char (point-min))
673 (if (re-search-forward "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]+>\\)" nil t)
674 (setq message-id (match-string 1))
676 (when (re-search-forward "^Message-ID[ \t]*:" nil t)
678 (insert "Original-")))
679 ;; There is no Message-ID here, so we create one.
681 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
682 ;; Look for a Content-Length header.
683 (goto-char (point-min))
684 (if (not (re-search-forward
685 "^Content-Length:[ \t]*\\([0-9]+\\)" nil t))
686 (setq content-length nil)
687 (setq content-length (string-to-int (match-string 1)))
688 ;; We destroy the header, since none of the backends ever
689 ;; use it, and we do not want to confuse other mailers by
690 ;; having a (possibly) faulty header.
693 (run-hooks 'nnmail-prepare-incoming-header-hook)
694 ;; Find the end of this article.
695 (goto-char (point-max))
697 (setq head-end (point))
698 ;; We try the Content-Length value. The idea: skip over the header
699 ;; separator, then check what happens content-length bytes into the
700 ;; message body. This should be either the end ot the buffer, the
701 ;; message separator or a blank line followed by the separator.
702 ;; The blank line should probably be deleted. If neither of the
703 ;; three is met, the content-length header is probably invalid.
706 (setq skip (+ (point) content-length))
708 (cond ((or (= skip (point-max))
709 (= (1+ skip) (point-max)))
710 (setq end (point-max)))
711 ((looking-at "From ")
713 ((looking-at "[ \t]*\n\\(From \\)")
714 (setq end (match-beginning 1)))
718 ;; No Content-Length, so we find the beginning of the next
719 ;; article or the end of the buffer.
721 (or (nnmail-search-unix-mail-delim)
722 (goto-char (point-max))))
723 ;; Allow the backend to save the article.
726 (narrow-to-region start (point))
727 (goto-char (point-min))
729 (nnmail-check-duplication message-id func artnum-func)
730 (setq end (point-max))))
734 (defun nnmail-process-mmdf-mail-format (func artnum-func)
735 (let ((delim "^\^A\^A\^A\^A$")
738 start message-id end)
739 (goto-char (point-min))
740 (if (not (and (re-search-forward delim nil t)
742 ;; Possibly wrong format?
743 (error "Error, unknown mail format! (Possibly corrupted.)")
744 ;; Carry on until the bitter end.
747 ;; Find the end of the head.
750 (if (search-forward "\n\n" nil t)
752 ;; This will never happen, but just to be on the safe side --
753 ;; if there is no head-body delimiter, we search a bit manually.
754 (while (and (looking-at "From \\|[^ \t]+:")
758 ;; Find the Message-ID header.
759 (goto-char (point-min))
760 (if (re-search-forward "^Message-ID[ \t]*:[ \n\t]*\\(<[^>]+>\\)" nil t)
761 (setq message-id (match-string 1))
762 ;; There is no Message-ID here, so we create one.
764 (when (re-search-backward "^Message-ID[ \t]*:" nil t)
766 (insert "Original-")))
768 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
769 (run-hooks 'nnmail-prepare-incoming-header-hook)
770 ;; Find the end of this article.
771 (goto-char (point-max))
773 (if (re-search-forward delim nil t)
775 (goto-char (point-max)))
776 ;; Allow the backend to save the article.
779 (narrow-to-region start (point))
780 (goto-char (point-min))
782 (nnmail-check-duplication message-id func artnum-func)
783 (setq end (point-max))))
788 (defun nnmail-process-maildir-mail-format (func artnum-func)
789 ;; In a maildir, every file contains exactly one mail.
790 (let ((case-fold-search t)
792 (goto-char (point-min))
793 ;; Find the end of the head.
796 (if (search-forward "\n\n" nil t)
798 ;; This will never happen, but just to be on the safe side --
799 ;; if there is no head-body delimiter, we search a bit manually.
800 (while (and (looking-at "From \\|[^ \t]+:")
804 ;; Find the Message-ID header.
805 (goto-char (point-min))
806 (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t)
807 (setq message-id (match-string 1))
808 ;; There is no Message-ID here, so we create one.
810 (when (re-search-backward "^Message-ID[ \t]*:" nil t)
812 (insert "Original-")))
814 (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
815 (run-hooks 'nnmail-prepare-incoming-header-hook)
816 ;; Allow the backend to save the article.
819 (goto-char (point-min))
820 (nnmail-check-duplication message-id func artnum-func))
823 (defun nnmail-split-incoming (incoming func &optional exit-func
825 "Go through the entire INCOMING file and pick out each individual mail.
826 FUNC will be called with the buffer narrowed to each mail."
827 (let (;; If this is a group-specific split, we bind the split
828 ;; methods to just this group.
829 (nnmail-split-methods (if (and group
830 (not nnmail-resplit-incoming))
831 (list (list group ""))
832 nnmail-split-methods)))
834 ;; Insert the incoming file.
835 (set-buffer (get-buffer-create " *nnmail incoming*"))
837 (let ((nnheader-file-coding-system nnmail-incoming-coding-system))
838 (mm-insert-file-contents incoming))
840 (if (zerop (buffer-size))
842 (goto-char (point-min))
843 (save-excursion (run-hooks 'nnmail-prepare-incoming-hook))
844 ;; Handle both babyl, MMDF and unix mail formats, since
845 ;; movemail will use the former when fetching from a
846 ;; mailbox, the latter when fetching from a file.
847 (cond ((or (looking-at "\^L")
848 (looking-at "BABYL OPTIONS:"))
849 (nnmail-process-babyl-mail-format func artnum-func))
850 ((looking-at "\^A\^A\^A\^A")
851 (nnmail-process-mmdf-mail-format func artnum-func))
852 ((looking-at "Return-Path:")
853 (nnmail-process-maildir-mail-format func artnum-func))
855 (nnmail-process-unix-mail-format func artnum-func))))
858 (kill-buffer (current-buffer))))))
860 (defun nnmail-article-group (func &optional trace)
861 "Look at the headers and return an alist of groups that match.
862 FUNC will be called with the group name to determine the article number."
863 (let ((methods nnmail-split-methods)
864 (obuf (current-buffer))
866 end group-art method grp)
867 (if (and (sequencep methods)
868 (= (length methods) 1))
869 ;; If there is only just one group to put everything in, we
870 ;; just return a list with just this one method in.
872 (list (cons (caar methods) (funcall func (caar methods)))))
873 ;; We do actual comparison.
877 (setq end (if (search-forward "\n\n" nil t) (point) (point-max)))
878 (set-buffer nntp-server-buffer)
880 ;; Copy the headers into the work buffer.
881 (insert-buffer-substring obuf beg end)
882 ;; Fold continuation lines.
883 (goto-char (point-min))
884 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
885 (replace-match " " t t))
886 ;; Nuke pathologically long headers. Since Gnus applies
887 ;; pathologically complex regexps to the buffer, lines
888 ;; that are looong will take longer than the Universe's
889 ;; existence to process.
890 (goto-char (point-min))
892 (unless (< (move-to-column nnmail-split-header-length-limit)
893 nnmail-split-header-length-limit)
894 (delete-region (point) (progn (end-of-line) (point))))
897 (goto-char (point-min))
898 (run-hooks 'nnmail-split-hook)
899 (when (setq nnmail-split-tracing trace)
900 (setq nnmail-split-trace nil))
901 (if (and (symbolp nnmail-split-methods)
902 (fboundp nnmail-split-methods))
905 ;; `nnmail-split-methods' is a function, so we
906 ;; just call this function here and use the
908 (or (funcall nnmail-split-methods)
912 "Error in `nnmail-split-methods'; using `bogus' mail group")
915 (setq split (gnus-remove-duplicates split))
916 ;; The article may be "cross-posted" to `junk'. What
917 ;; to do? Just remove the `junk' spec. Don't really
918 ;; see anything else to do...
920 (while (setq elem (car (memq 'junk split)))
921 (setq split (delq elem split))))
925 (lambda (group) (cons group (funcall func group)))
927 ;; Go through the split methods to find a match.
931 (goto-char (point-max))
932 (setq method (pop methods)
935 (not (equal "" (nth 1 method))))
938 (if (stringp (nth 1 method))
939 (let ((expand (string-match "\\\\[0-9&]" grp))
940 (pos (re-search-backward (cadr method)
943 (setq grp (nnmail-expand-newtext grp)))
945 ;; Function to say whether this is a match.
946 (funcall (nth 1 method) grp)))
947 ;; Don't enter the article into the same
949 (not (assoc grp group-art)))
950 (push (cons grp (funcall func grp))
952 ;; This is the final group, which is used as a
956 (list (cons (car method)
957 (funcall func (car method)))))))))
958 ;; Produce a trace if non-empty.
959 (when (and trace nnmail-split-trace)
960 (let ((trace (nreverse nnmail-split-trace))
961 (restore (current-buffer)))
962 (nnheader-set-temp-buffer "*Split Trace*")
965 (insert (car trace) "\n")
966 (setq trace (cdr trace)))
967 (goto-char (point-min))
968 (gnus-configure-windows 'split-trace)
969 (set-buffer restore)))
970 ;; See whether the split methods returned `junk'.
971 (if (equal group-art '(junk))
973 ;; The article may be "cross-posted" to `junk'. What
974 ;; to do? Just remove the `junk' spec. Don't really
975 ;; see anything else to do...
977 (while (setq elem (car (memq 'junk group-art)))
978 (setq group-art (delq elem group-art)))
979 (nreverse group-art)))))))
981 (defun nnmail-insert-lines ()
982 "Insert how many lines there are in the body of the mail.
983 Return the number of characters in the body."
986 (goto-char (point-min))
987 (when (search-forward "\n\n" nil t)
988 (setq chars (- (point-max) (point)))
989 (setq lines (count-lines (point) (point-max)))
992 (when (re-search-backward "^Lines: " nil t)
993 (delete-region (point) (progn (forward-line 1) (point)))))
995 (insert (format "Lines: %d\n" (max lines 0)))
998 (defun nnmail-insert-xref (group-alist)
999 "Insert an Xref line based on the (group . article) alist."
1001 (goto-char (point-min))
1002 (when (search-forward "\n\n" nil t)
1004 (when (re-search-backward "^Xref: " nil t)
1005 (delete-region (match-beginning 0)
1006 (progn (forward-line 1) (point))))
1007 (insert (format "Xref: %s" (system-name)))
1009 (insert (format " %s:%d"
1010 (mm-encode-coding-string
1012 nnmail-pathname-coding-system)
1013 (cdar group-alist)))
1014 (setq group-alist (cdr group-alist)))
1017 ;;; Message washing functions
1019 (defun nnmail-remove-leading-whitespace ()
1020 "Remove excessive whitespace from all headers."
1021 (goto-char (point-min))
1022 (while (re-search-forward "^\\([^ :]+: \\) +" nil t)
1023 (replace-match "\\1" t)))
1025 (defun nnmail-remove-list-identifiers ()
1026 "Remove list identifiers from Subject headers."
1027 (let ((regexp (if (stringp nnmail-list-identifiers) nnmail-list-identifiers
1028 (mapconcat 'identity nnmail-list-identifiers "\\|"))))
1030 (goto-char (point-min))
1031 (when (re-search-forward
1032 (concat "^Subject: +\\(Re: +\\)?\\(" regexp "\\) *")
1034 (delete-region (match-beginning 2) (match-end 0))))))
1036 (defun nnmail-remove-tabs ()
1037 "Translate TAB characters into SPACE characters."
1038 (subst-char-in-region (point-min) (point-max) ?\t ? t))
1040 (defun nnmail-fix-eudora-headers ()
1041 "Eudora has a broken References line, but an OK In-Reply-To."
1042 (goto-char (point-min))
1043 (when (re-search-forward "^X-Mailer:.*Eudora" nil t)
1044 (goto-char (point-min))
1045 (when (re-search-forward "^References:" nil t)
1047 (insert "X-Gnus-Broken-Eudora-"))))
1049 (custom-add-option 'nnmail-prepare-incoming-header-hook
1050 'nnmail-fix-eudora-headers)
1052 ;;; Utility functions
1054 (defun nnmail-split-fancy ()
1055 "Fancy splitting method.
1056 See the documentation for the variable `nnmail-split-fancy' for documentation."
1057 (let ((syntab (syntax-table)))
1060 (set-syntax-table nnmail-split-fancy-syntax-table)
1061 (nnmail-split-it nnmail-split-fancy))
1062 (set-syntax-table syntab))))
1064 (defvar nnmail-split-cache nil)
1065 ;; Alist of split expressions their equivalent regexps.
1067 (defun nnmail-split-it (split)
1068 ;; Return a list of groups matching SPLIT.
1075 ;; A group name. Do the \& and \N subs into the string.
1077 (when nnmail-split-tracing
1078 (push (format "\"%s\"" split) nnmail-split-trace))
1079 (list (nnmail-expand-newtext split)))
1081 ;; Junk the message.
1083 (when nnmail-split-tracing
1084 (push "junk" nnmail-split-trace))
1087 ;; Builtin & operation.
1088 ((eq (car split) '&)
1089 (apply 'nconc (mapcar 'nnmail-split-it (cdr split))))
1091 ;; Builtin | operation.
1092 ((eq (car split) '|)
1094 (while (and (not done) (cdr split))
1095 (setq split (cdr split)
1096 done (nnmail-split-it (car split))))
1099 ;; Builtin : operation.
1100 ((eq (car split) ':)
1101 (nnmail-split-it (save-excursion (eval (cdr split)))))
1103 ;; Builtin ! operation.
1104 ((eq (car split) '!)
1105 (funcall (cadr split) (nnmail-split-it (caddr split))))
1107 ;; Check the cache for the regexp for this split.
1108 ((setq cached-pair (assq split nnmail-split-cache))
1109 (goto-char (point-max))
1110 ;; FIX FIX FIX problem with re-search-backward is that if you have
1111 ;; a split: (from "foo-\\(bar\\|baz\\)@gnus.org "mail.foo.\\1")
1112 ;; and someone mails a message with 'To: foo-bar@gnus.org' and
1113 ;; 'CC: foo-baz@gnus.org', we'll pick 'mail.foo.baz' as the group
1114 ;; if the cc line is a later header, even though the other choice
1115 ;; is probably better. Also, this routine won't do a crosspost
1116 ;; when there are two different matches.
1117 ;; I guess you could just make this more determined, and it could
1118 ;; look for still more matches prior to this one, and recurse
1119 ;; on each of the multiple matches hit. Of course, then you'd
1120 ;; want to make sure that nnmail-article-group or nnmail-split-fancy
1121 ;; removed duplicates, since there might be more of those.
1122 ;; I guess we could also remove duplicates in the & split case, since
1123 ;; that's the only thing that can introduce them.
1124 (when (re-search-backward (cdr cached-pair) nil t)
1125 (when nnmail-split-tracing
1126 (push (cdr cached-pair) nnmail-split-trace))
1127 ;; Someone might want to do a \N sub on this match, so get the
1128 ;; correct match positions.
1129 (goto-char (match-end 0))
1130 (let ((value (nth 1 split)))
1131 (re-search-backward (if (symbolp value)
1132 (cdr (assq value nnmail-split-abbrev-alist))
1135 (nnmail-split-it (nth 2 split))))
1137 ;; Not in cache, compute a regexp for the field/value pair.
1139 (let* ((field (nth 0 split))
1140 (value (nth 1 split))
1141 (regexp (concat "^\\(\\("
1143 (cdr (assq field nnmail-split-abbrev-alist))
1147 (cdr (assq value nnmail-split-abbrev-alist))
1150 (push (cons split regexp) nnmail-split-cache)
1151 ;; Now that it's in the cache, just call nnmail-split-it again
1152 ;; on the same split, which will find it immediately in the cache.
1153 (nnmail-split-it split))))))
1155 (defun nnmail-expand-newtext (newtext)
1156 (let ((len (length newtext))
1158 c expanded beg N did-expand)
1161 (while (and (< pos len)
1162 (not (= (aref newtext pos) ?\\)))
1163 (setq pos (1+ pos)))
1165 (push (substring newtext beg pos) expanded))
1167 ;; We hit a \; expand it.
1170 c (aref newtext pos))
1171 (if (not (or (= c ?\&)
1174 ;; \ followed by some character we don't expand.
1175 (push (char-to-string c) expanded)
1180 (when (match-beginning N)
1181 (push (buffer-substring (match-beginning N) (match-end N))
1183 (setq pos (1+ pos)))
1185 (apply 'concat (nreverse expanded))
1188 ;; Activate a backend only if it isn't already activated.
1189 ;; If FORCE, re-read the active file even if the backend is
1190 ;; already activated.
1191 (defun nnmail-activate (backend &optional force)
1192 (nnheader-init-server-buffer)
1193 (let (file timestamp file-time)
1194 (if (or (not (symbol-value (intern (format "%s-group-alist" backend))))
1196 (and (setq file (ignore-errors
1197 (symbol-value (intern (format "%s-active-file"
1199 (setq file-time (nth 5 (file-attributes file)))
1203 (symbol-value (intern
1204 (format "%s-active-timestamp"
1207 (not (consp timestamp))
1208 (equal timestamp '(0 0))
1209 (> (nth 0 file-time) (nth 0 timestamp))
1210 (and (= (nth 0 file-time) (nth 0 timestamp))
1211 (> (nth 1 file-time) (nth 1 timestamp))))))
1213 (or (eq timestamp 'none)
1214 (set (intern (format "%s-active-timestamp" backend))
1216 (funcall (intern (format "%s-request-list" backend)))))
1219 (defun nnmail-message-id ()
1220 (concat "<" (message-unique-id) "@totally-fudged-out-message-id>"))
1223 ;;; nnmail duplicate handling
1226 (defvar nnmail-cache-buffer nil)
1228 (defun nnmail-cache-open ()
1229 (if (or (not nnmail-treat-duplicates)
1230 (and nnmail-cache-buffer
1231 (buffer-name nnmail-cache-buffer)))
1232 () ; The buffer is open.
1235 (setq nnmail-cache-buffer
1236 (get-buffer-create " *nnmail message-id cache*")))
1237 (when (file-exists-p nnmail-message-id-cache-file)
1238 (mm-insert-file-contents nnmail-message-id-cache-file))
1239 (set-buffer-modified-p nil)
1242 (defun nnmail-cache-close ()
1243 (when (and nnmail-cache-buffer
1244 nnmail-treat-duplicates
1245 (buffer-name nnmail-cache-buffer)
1246 (buffer-modified-p nnmail-cache-buffer))
1248 (set-buffer nnmail-cache-buffer)
1249 ;; Weed out the excess number of Message-IDs.
1250 (goto-char (point-max))
1251 (when (search-backward "\n" nil t nnmail-message-id-cache-length)
1254 (delete-region (point-min) (point))))
1256 (or (file-exists-p (file-name-directory nnmail-message-id-cache-file))
1257 (make-directory (file-name-directory nnmail-message-id-cache-file)
1259 (nnmail-write-region (point-min) (point-max)
1260 nnmail-message-id-cache-file nil 'silent)
1261 (set-buffer-modified-p nil)
1262 (setq nnmail-cache-buffer nil)
1263 (kill-buffer (current-buffer)))))
1265 (defun nnmail-cache-insert (id)
1266 (when nnmail-treat-duplicates
1267 (unless (gnus-buffer-live-p nnmail-cache-buffer)
1268 (nnmail-cache-open))
1270 (set-buffer nnmail-cache-buffer)
1271 (goto-char (point-max))
1274 (defun nnmail-cache-id-exists-p (id)
1275 (when nnmail-treat-duplicates
1277 (set-buffer nnmail-cache-buffer)
1278 (goto-char (point-max))
1279 (search-backward id nil t))))
1281 (defun nnmail-fetch-field (header)
1284 (message-narrow-to-head)
1285 (message-fetch-field header))))
1287 (defun nnmail-check-duplication (message-id func artnum-func)
1288 (run-hooks 'nnmail-prepare-incoming-message-hook)
1289 ;; If this is a duplicate message, then we do not save it.
1290 (let* ((duplication (nnmail-cache-id-exists-p message-id))
1291 (case-fold-search t)
1292 (action (when duplication
1294 ((memq nnmail-treat-duplicates '(warn delete))
1295 nnmail-treat-duplicates)
1296 ((nnheader-functionp nnmail-treat-duplicates)
1297 (funcall nnmail-treat-duplicates message-id))
1299 nnmail-treat-duplicates))))
1301 ;; We insert a line that says what the mail source is.
1302 (let ((case-fold-search t))
1303 (goto-char (point-min))
1304 (re-search-forward "^message-id[ \t]*:" nil t)
1306 (insert (format "X-Gnus-Mail-Source: %s\n" mail-source-string)))
1308 ;; Let the backend save the article (or not).
1311 (funcall func (setq group-art
1312 (nreverse (nnmail-article-group artnum-func))))
1313 (nnmail-cache-insert message-id))
1314 ((eq action 'delete)
1315 (setq group-art nil))
1317 ;; We insert a warning.
1318 (let ((case-fold-search t))
1319 (goto-char (point-min))
1320 (re-search-forward "^message-id[ \t]*:" nil t)
1323 "Gnus-Warning: This is a duplicate of message " message-id "\n")
1324 (funcall func (setq group-art
1325 (nreverse (nnmail-article-group artnum-func))))))
1327 (funcall func (setq group-art
1328 (nreverse (nnmail-article-group artnum-func))))))
1329 ;; Add the group-art list to the history list.
1331 (push group-art nnmail-split-history)
1332 (delete-region (point-min) (point-max)))))
1336 (defvar nnmail-fetched-sources nil)
1338 (defun nnmail-get-value (&rest args)
1339 (let ((sym (intern (apply 'format args))))
1341 (symbol-value sym))))
1343 (defun nnmail-get-new-mail (method exit-func temp
1344 &optional group spool-func)
1345 "Read new incoming mail."
1346 (let* ((sources (or mail-sources
1347 (if (listp nnmail-spool-file) nnmail-spool-file
1348 (list nnmail-spool-file))))
1353 incoming incomings source)
1354 (when (and (nnmail-get-value "%s-get-new-mail" method)
1356 ;; We first activate all the groups.
1357 (nnmail-activate method)
1358 ;; Allow the user to hook.
1359 (run-hooks 'nnmail-pre-get-new-mail-hook)
1360 ;; Open the message-id cache.
1362 ;; The we go through all the existing mail source specification
1363 ;; and fetch the mail from each.
1364 (while (setq source (pop sources))
1365 ;; Be compatible with old values.
1370 ((string-match "^po:" source)
1371 (list 'pop :user (substring source (match-end 0))))
1372 ((file-directory-p source)
1373 (list 'directory :path source))
1375 (list 'file :path source)))))
1376 ((eq source 'procmail)
1377 (message "Invalid value for nnmail-spool-file: `procmail'")
1379 ;; Hack to only fetch the contents of a single group's spool file.
1380 (when (and (eq (car source) 'directory)
1382 (mail-source-bind (directory source)
1383 (setq source (append source
1389 (regexp-quote (concat group suffix))
1392 (when nnmail-fetched-sources
1393 (if (member source nnmail-fetched-sources)
1395 (push source nnmail-fetched-sources)))
1397 (nnheader-message 4 "%s: Reading incoming mail from %s..."
1398 method (car source))
1402 `(lambda (file orig-file)
1403 (nnmail-split-incoming
1404 file ',(intern (format "%s-save-mail" method))
1406 (nnmail-get-split-group orig-file source)
1407 ',(intern (format "%s-active-number" method))))))
1410 ;; If we did indeed read any incoming spools, we save all info.
1411 (unless (zerop total)
1413 (nnmail-get-value "%s-group-alist" method)
1414 (nnmail-get-value "%s-active-file" method))
1416 (funcall exit-func))
1417 (run-hooks 'nnmail-read-incoming-hook)
1418 (nnheader-message 4 "%s: Reading incoming mail (%d new)...done" method
1420 ;; Close the message-id cache.
1421 (nnmail-cache-close)
1422 ;; Allow the user to hook.
1423 (run-hooks 'nnmail-post-get-new-mail-hook))))
1425 (defun nnmail-expired-article-p (group time force &optional inhibit)
1426 "Say whether an article that is TIME old in GROUP should be expired."
1429 (let ((days (or (and nnmail-expiry-wait-function
1430 (funcall nnmail-expiry-wait-function group))
1431 nnmail-expiry-wait)))
1432 (cond ((or (eq days 'never)
1435 ;; This isn't an expirable group.
1437 ((eq days 'immediate)
1438 ;; We expire all articles on sight.
1440 ((equal time '(0 0))
1441 ;; This is an ange-ftp group, and we don't have any dates.
1444 (setq days (days-to-time days))
1445 ;; Compare the time with the current time.
1446 (ignore-errors (time-less-p days (time-since time))))))))
1448 (defun nnmail-check-syntax ()
1449 "Check (and modify) the syntax of the message in the current buffer."
1451 (message-narrow-to-head)
1452 (let ((case-fold-search t))
1453 (unless (re-search-forward "^Message-ID[ \t]*:" nil t)
1454 (insert "Message-ID: " (nnmail-message-id) "\n")))))
1456 (defun nnmail-write-region (start end filename &optional append visit lockname)
1457 "Do a `write-region', and then set the file modes."
1458 (let ((coding-system-for-write nnmail-file-coding-system)
1459 (pathname-coding-system nnmail-pathname-coding-system))
1460 (write-region start end filename append visit lockname)
1461 (set-file-modes filename nnmail-default-file-modes)))
1464 ;;; Status functions
1467 (defun nnmail-replace-status (name value)
1468 "Make status NAME and VALUE part of the current status line."
1470 (message-narrow-to-head)
1471 (let ((status (nnmail-decode-status)))
1472 (setq status (delq (member name status) status))
1474 (push (cons name value) status))
1475 (message-remove-header "status")
1476 (goto-char (point-max))
1477 (insert "Status: " (nnmail-encode-status status) "\n"))))
1479 (defun nnmail-decode-status ()
1480 "Return a status-value alist from STATUS."
1481 (goto-char (point-min))
1482 (when (re-search-forward "^Status: " nil t)
1483 (let (name value status)
1485 ;; Narrow to the status.
1488 (if (re-search-forward "^[^ \t]" nil t)
1491 ;; Go through all elements and add them to the list.
1492 (goto-char (point-min))
1493 (while (re-search-forward "[^ \t=]+" nil t)
1494 (setq name (match-string 0))
1495 (if (not (eq (char-after) ?=))
1499 (if (not (eq (char-after) ?\"))
1500 (if (not (looking-at "[^ \t]"))
1504 (setq value (match-string 0))
1505 (goto-char (match-end 0)))
1507 (setq value (read (current-buffer)))))
1508 (push (cons name value) status)))
1511 (defun nnmail-encode-status (status)
1512 "Return a status string from STATUS."
1517 (if (string-match "[ \t]" (cdr elem))
1518 (prin1-to-string (cdr elem))
1522 (defun nnmail-split-history ()
1523 "Generate an overview of where the last mail split put articles."
1525 (unless nnmail-split-history
1526 (error "No current split history"))
1527 (with-output-to-temp-buffer "*nnmail split history*"
1528 (let ((history nnmail-split-history)
1530 (while (setq elem (pop history))
1531 (princ (mapconcat (lambda (ga)
1532 (concat (car ga) ":" (int-to-string (cdr ga))))
1537 (defun nnmail-purge-split-history (group)
1538 "Remove all instances of GROUP from `nnmail-split-history'."
1539 (let ((history nnmail-split-history))
1541 (setcar history (gnus-delete-if (lambda (e) (string= (car e) group))
1544 (setq nnmail-split-history (delq nil nnmail-split-history))))
1546 (defun nnmail-new-mail-p (group)
1547 "Say whether GROUP has new mail."
1548 (let ((his nnmail-split-history)
1551 (when (assoc group (pop his))
1556 (defun nnmail-within-headers-p ()
1557 "Check to see if point is within the headers of a unix mail message.
1558 Doesn't change point."
1559 (let ((pos (point)))
1561 (and (nnmail-search-unix-mail-delim-backward)
1562 (not (search-forward "\n\n" pos t))))))
1564 (run-hooks 'nnmail-load-hook)
1568 ;;; nnmail.el ends here