*** empty log message ***
[gnus] / lisp / nnmail.el
index c6cb367..5c0cd70 100644 (file)
@@ -1,5 +1,5 @@
 ;;; nnmail.el --- mail support functions for the Gnus mail backends
-;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
 ;; Keywords: news, mail
@@ -33,7 +33,9 @@
 (require 'custom)
 
 (eval-and-compile
-  (autoload 'gnus-error "gnus-util"))
+  (autoload 'gnus-error "gnus-util")
+  (autoload 'gnus-buffer-live-p "gnus-util")
+  (autoload 'gnus-encode-coding-string "gnus-ems"))
 
 (defgroup nnmail nil
   "Reading mail with Gnus."
@@ -74,7 +76,7 @@
 
 (defcustom nnmail-split-methods
   '(("mail.misc" ""))
-  "Incoming mail will be split according to this variable.
+  "*Incoming mail will be split according to this variable.
 
 If you'd like, for instance, one mail group for mail from the
 \"4ad-l\" mailing list, one group for junk mail and one for everything
@@ -171,7 +173,7 @@ Eg.:
 (defcustom nnmail-spool-file
   (or (getenv "MAIL")
       (concat "/usr/spool/mail/" (user-login-name)))
-  "Where the mail backends will look for incoming mail.
+  "*Where the mail backends will look for incoming mail.
 This variable is \"/usr/spool/mail/$user\" by default.
 If this variable is nil, no mail backends will read incoming mail.
 If this variable is a list, all files mentioned in this list will be
@@ -219,7 +221,7 @@ several files - eg. \".spool[0-9]*\"."
   (if (string-match "windows-nt\\|emx" (format "%s" system-type))
       'copy-file
     'add-name-to-file)
-  "Function called to create a copy of a file.
+  "*Function called to create a copy of a file.
 This is `add-name-to-file' by default, which means that crossposts
 will use hard links.  If your file system doesn't allow hard
 links, you could set this variable to `copy-file' instead."
@@ -248,7 +250,7 @@ to be moved to."
   (if (eq system-type 'windows-nt)
       '(nnheader-ms-strip-cr)
     nil)
-  "Hook that will be run after the incoming mail has been transferred.
+  "*Hook that will be run after the incoming mail has been transferred.
 The incoming mail is moved from `nnmail-spool-file' (which normally is
 something like \"/usr/spool/mail/$user\") to the user's home
 directory.  This hook is called after the incoming mail box has been
@@ -401,7 +403,7 @@ Example:
     (from . "from\\|sender\\|resent-from")
     (nato . "to\\|cc\\|resent-to\\|resent-cc")
     (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc"))
-  "Alist of abbreviations allowed in `nnmail-split-fancy'."
+  "*Alist of abbreviations allowed in `nnmail-split-fancy'."
   :group 'nnmail-split
   :type '(repeat (cons :format "%v" symbol regexp)))
 
@@ -476,7 +478,6 @@ parameter.  It should return nil, `warn' or `delete'."
 (defun nnmail-request-post (&optional server)
   (mail-send-and-exit nil))
 
-;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
 (defvar nnmail-file-coding-system 'raw-text
   "Coding system used in nnmail.")
 
@@ -487,16 +488,12 @@ parameter.  It should return nil, `warn' or `delete'."
   (let ((format-alist nil)
         (after-insert-file-functions nil))
     (condition-case ()
-       ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
        (let ((coding-system-for-read nnmail-file-coding-system)
-             ;; 1997/8/12 by MORIOKA Tomohiko
-             ;;        for XEmacs/mule.
              (pathname-coding-system 'binary))
          (insert-file-contents file)
          t)
       (file-error nil))))
 
-;; 1997/8/10 by MORIOKA Tomohiko
 (defvar nnmail-pathname-coding-system
   'iso-8859-1
   "*Coding system for pathname.")
@@ -693,7 +690,6 @@ nn*-request-list should have been called before calling this function."
              group-assoc)))
     group-assoc))
 
-;; 1997/8/12 by MORIOKA Tomohiko
 (defvar nnmail-active-file-coding-system
   'iso-8859-1
   "*Coding system for active file.")
@@ -740,8 +736,8 @@ is a spool.  If not using procmail, return GROUP."
 (defun nnmail-process-babyl-mail-format (func artnum-func)
   (let ((case-fold-search t)
        start message-id content-length do-search end)
-    (goto-char (point-min))
     (while (not (eobp))
+      (goto-char (point-min))
       (re-search-forward
        "\f\n0, *unseen,+\n\\(\\*\\*\\* EOOH \\*\\*\\*\n\\)?" nil t)
       (goto-char (match-end 0))
@@ -1052,7 +1048,8 @@ FUNC will be called with the group name to determine the article number."
        (obuf (current-buffer))
        (beg (point-min))
        end group-art method regrepp)
-    (if (and (sequencep methods) (= (length methods) 1))
+    (if (and (sequencep methods)
+            (= (length methods) 1))
        ;; If there is only just one group to put everything in, we
        ;; just return a list with just this one method in.
        (setq group-art
@@ -1086,6 +1083,7 @@ FUNC will be called with the group name to determine the article number."
                       "Error in `nnmail-split-methods'; using `bogus' mail group")
                      (sit-for 1)
                      '("bogus")))))
+             (setq split (remove-duplicates split :test 'equal))
              ;; The article may be "cross-posted" to `junk'.  What
              ;; to do?  Just remove the `junk' spec.  Don't really
              ;; see anything else to do...
@@ -1663,10 +1661,7 @@ If ARGS, PROMPT is used as an argument to `format'."
 
 (defun nnmail-write-region (start end filename &optional append visit lockname)
   "Do a `write-region', and then set the file modes."
-  ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
   (let ((coding-system-for-write nnmail-file-coding-system)
-       ;; 1997/8/12 by MORIOKA Tomohiko
-       ;;      for XEmacs/mule.
        (pathname-coding-system 'binary))
     (write-region start end filename append visit lockname)
     (set-file-modes filename nnmail-default-file-modes)))
@@ -1746,15 +1741,14 @@ If ARGS, PROMPT is used as an argument to `format'."
        (princ "\n")))))
 
 (defun nnmail-purge-split-history (group)
-  (let ((history nnmail-split-history))
+  "Remove all instances of GROUP from `nnmail-split-history'."
+  (let ((history nnmail-split-history)
+       prev)
     (while history
-      (let ((pairs (car history)))
-       (while pairs
-         (if (string= (car (car pairs)) group)
-             (setcar pairs (cdr pairs))
-           (setq pairs (cdr pairs)))))
-      (setq history (cdr history))))
-  (setq nnmail-split-history (delq nil nnmail-split-history)))
+      (setcar history (delete-if (lambda (e) (string= (car e) group))
+                                (car history)))
+      (pop history))
+    (setq nnmail-split-history (delq nil nnmail-split-history))))
 
 (defun nnmail-new-mail-p (group)
   "Say whether GROUP has new mail."