Importing Oort Gnus v0.06.
[elisp/gnus.git-] / lisp / nnmail.el
index 334d37f..9538167 100644 (file)
@@ -189,7 +189,7 @@ The return value should be `delete' or a group name (a string)."
                 (function :format "%v" nnmail-)
                 string))
 
-(defcustom nnmail-fancy-expiry-targets nil 
+(defcustom nnmail-fancy-expiry-targets nil
   "Determine expiry target based on articles using fancy techniques.
 
 This is a list of (\"HEADER\" \"REGEXP\" \"TARGET\") entries.  If
@@ -219,8 +219,8 @@ everything else will be expired to \"nnfolder:Archive-YYYY\"."
   :type '(repeat (list (choice :tag "Match against"
                               (string :tag "Header")
                               (const to-from))
-                       regexp
-                       (string :tag "Target group format string"))))
+                      regexp
+                      (string :tag "Target group format string"))))
 
 (defcustom nnmail-cache-accepted-message-ids nil
   "If non-nil, put Message-IDs of Gcc'd articles into the duplicate cache.
@@ -342,11 +342,12 @@ discarded after running the split process."
   :type 'hook)
 
 (defcustom nnmail-large-newsgroup 50
-  "*The number of the articles which indicates a large newsgroup.
+  "*The number of the articles which indicates a large newsgroup or nil.
 If the number of the articles is greater than the value, verbose
 messages will be shown to indicate the current status."
   :group 'nnmail-various
-  :type 'integer)
+  :type '(choice (const :tag "infinite" nil)
+                 (number :tag "count")))
 
 (defcustom nnmail-split-fancy "mail.misc"
   "Incoming mail can be split according to this fancy variable.
@@ -381,8 +382,8 @@ GROUP: Mail will be stored in GROUP (a string).
 junk: Mail will be deleted.  Use with care!  Do not submerge in water!
   Example:
   (setq nnmail-split-fancy
-        '(| (\"Subject\" \"MAKE MONEY FAST\" junk)
-            ...other.rules.omitted...))
+       '(| (\"Subject\" \"MAKE MONEY FAST\" junk)
+           ...other.rules.omitted...))
 
 FIELD must match a complete field name.  VALUE must match a complete
 word according to the `nnmail-split-fancy-syntax-table' syntax table.
@@ -478,6 +479,11 @@ parameter.  It should return nil, `warn' or `delete'."
   :group 'nnmail
   :type 'integer)
 
+(defcustom nnmail-mail-splitting-charset nil
+  "Default charset to be used when splitting incoming mail."
+  :group 'nnmail
+  :type 'symbol)
+
 ;;; Internal variables.
 
 (defvar nnmail-article-buffer " *nnmail incoming*"
@@ -993,6 +999,9 @@ FUNC will be called with the group name to determine the article number."
        (erase-buffer)
        ;; Copy the headers into the work buffer.
        (insert-buffer-substring obuf beg end)
+       ;; Decode MIME headers and charsets.
+       (let ((mail-parse-charset nnmail-mail-splitting-charset))
+         (mail-decode-encoded-word-region (point-min) (point-max)))
        ;; Fold continuation lines.
        (goto-char (point-min))
        (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
@@ -1022,8 +1031,8 @@ FUNC will be called with the group name to determine the article number."
                       (or (funcall nnmail-split-methods)
                           '("bogus"))
                     (error
-                     (nnheader-message 5
-                                       "Error in `nnmail-split-methods'; using `bogus' mail group")
+                     (nnheader-message
+                      5 "Error in `nnmail-split-methods'; using `bogus' mail group")
                      (sit-for 1)
                      '("bogus")))))
              (setq split (gnus-remove-duplicates split))
@@ -1075,7 +1084,8 @@ FUNC will be called with the group name to determine the article number."
            (nnheader-set-temp-buffer "*Split Trace*")
            (gnus-add-buffer)
            (dolist (trace (nreverse nnmail-split-trace))
-             (insert trace "\n"))
+             (prin1 trace (current-buffer))
+             (insert "\n"))
            (goto-char (point-min))
            (gnus-configure-windows 'split-trace)
            (set-buffer restore)))
@@ -1222,7 +1232,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
      ;; A group name.  Do the \& and \N subs into the string.
      ((stringp split)
       (when nnmail-split-tracing
-       (push (format "\"%s\"" split) nnmail-split-trace))
+       (push split nnmail-split-trace))
       (list (nnmail-expand-newtext split)))
 
      ;; Junk the message.
@@ -1261,7 +1271,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
        (while (and (goto-char end-point)
                    (re-search-backward (cdr cached-pair) nil t))
          (when nnmail-split-tracing
-           (push (cdr cached-pair) nnmail-split-trace))
+           (push split nnmail-split-trace))
          (let ((split-rest (cddr split))
                (end (match-end 0))
                ;; The searched regexp is \(\(FIELD\).*\)\(VALUE\).
@@ -1291,7 +1301,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
              (let ((value (nth 1 split)))
                (if (symbolp value)
                    (setq value (cdr (assq value nnmail-split-abbrev-alist))))
-       ;; Someone might want to do a \N sub on this match, so get the
+               ;; Someone might want to do a \N sub on this match, so get the
                ;; correct match positions.
                (re-search-backward value start-of-value))
              (dolist (sp (nnmail-split-it (car split-rest)))
@@ -1446,7 +1456,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
 (defvar group)
 (defvar group-art-list)
 (defvar group-art)
-(defun nnmail-cache-insert (id)
+(defun nnmail-cache-insert (id &optional grp)
   (when nnmail-treat-duplicates
     ;; Store some information about the group this message is written
     ;; to.  This function might have been called from various places.
@@ -1457,7 +1467,9 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
     ;; the car of a pair is a group name.  Should we check that the
     ;; length of the list is equal to 1? -- kai
     (let ((g nil))
-      (cond ((and (boundp 'group) group)
+      (cond (grp
+            (setq g grp))
+           ((and (boundp 'group) group)
             (setq g group))
            ((and (boundp 'group-art-list) group-art-list
                  (listp group-art-list))