Importing Pterodactyl Gnus v0.52.
[elisp/gnus.git-] / lisp / nnmail.el
index 383b472..c852ad8 100644 (file)
@@ -28,7 +28,6 @@
 (eval-when-compile (require 'cl))
 
 (require 'nnheader)
-(require 'timezone)
 (require 'message)
 (require 'custom)
 (require 'gnus-util)
@@ -242,6 +241,13 @@ to be moved to."
   :group 'nnmail-retrieve
   :type 'string)
 
+(defcustom nnmail-movemail-args nil
+  "*Extra arguments to give to `nnmail-movemail-program'  to move mail from the inbox.
+The default is nil"
+  :group 'nnmail-files
+  :group 'nnmail-retrieve
+  :type 'string)
+
 (defcustom nnmail-pop-password-required nil
   "*Non-nil if a password is required when reading mail using POP."
   :group 'nnmail-retrieve
@@ -443,6 +449,11 @@ parameter.  It should return nil, `warn' or `delete'."
                 (const warn)
                 (const delete)))
 
+(defcustom nnmail-extra-headers nil
+  "*Extra headers to parse."
+  :group 'nnmail
+  :type '(repeat symbol))
+
 ;;; Internal variables.
 
 (defvar nnmail-split-history nil
@@ -488,11 +499,12 @@ parameter.  It should return nil, `warn' or `delete'."
 (defun nnmail-find-file (file)
   "Insert FILE in server buffer safely."
   (set-buffer nntp-server-buffer)
-  (erase-buffer)
+  (delete-region (point-min) (point-max))
   (let ((format-alist nil)
         (after-insert-file-functions nil))
     (condition-case ()
        (let ((coding-system-for-read nnmail-file-coding-system)
+             (auto-mode-alist (nnheader-auto-mode-alist))
              (pathname-coding-system nnmail-file-coding-system))
          (insert-file-contents file)
          t)
@@ -513,7 +525,7 @@ parameter.  It should return nil, `warn' or `delete'."
         (concat dir group "/")
        ;; If not, we translate dots into slashes.
        (concat dir
-              (nnheader-encode-coding-string
+              (mm-encode-coding-string
                (nnheader-replace-chars-in-string group ?. ?/)
                nnmail-pathname-coding-system)
               "/")))
@@ -597,7 +609,9 @@ parameter.  It should return nil, `warn' or `delete'."
                              nnmail-movemail-program exec-directory)
                             nil errors nil inbox tofile)
                            (when nnmail-internal-password
-                             (list nnmail-internal-password)))))))
+                             (list nnmail-internal-password))
+                           (when nnmail-movemail-args
+                             nnmail-movemail-args))))))
                (push inbox nnmail-moved-inboxes)
                (if (and (not (buffer-modified-p errors))
                         (zerop result))
@@ -794,7 +808,7 @@ is a spool.  If not using procmail, return GROUP."
          (when (and (or (bobp)
                         (save-excursion
                           (forward-line -1)
-                          (= (following-char) ?\n)))
+                          (eq (char-after) ?\n)))
                     (save-excursion
                       (forward-line 1)
                       (while (looking-at ">From \\|From ")
@@ -823,7 +837,7 @@ is a spool.  If not using procmail, return GROUP."
          (when (and (or (bobp)
                         (save-excursion
                           (forward-line -1)
-                          (= (following-char) ?\n)))
+                          (eq (char-after) ?\n)))
                     (save-excursion
                       (forward-line 1)
                       (while (looking-at ">From \\|From ")
@@ -987,7 +1001,6 @@ FUNC will be called with the buffer narrowed to each mail."
     (save-excursion
       ;; Insert the incoming file.
       (set-buffer (get-buffer-create " *nnmail incoming*"))
-      (buffer-disable-undo (current-buffer))
       (erase-buffer)
       (nnheader-insert-file-contents incoming)
       (unless (zerop (buffer-size))
@@ -1096,8 +1109,7 @@ FUNC will be called with the group name to determine the article number."
                       ;; group twice.
                       (not (assoc (car method) group-art)))
                  (push (cons (if regrepp
-                                 (replace-match
-                                  (car method) nil nil (car method))
+                                 (nnmail-expand-newtext (car method))
                                (car method))
                              (funcall func (car method)))
                        group-art))
@@ -1159,7 +1171,7 @@ Return the number of characters in the body."
       (insert (format "Xref: %s" (system-name)))
       (while group-alist
        (insert (format " %s:%d"
-                       (nnheader-encode-coding-string
+                       (mm-encode-coding-string
                         (caar group-alist)
                         nnmail-pathname-coding-system)
                        (cdar group-alist)))
@@ -1442,7 +1454,6 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
       (set-buffer
        (setq nnmail-cache-buffer
             (get-buffer-create " *nnmail message-id cache*")))
-      (buffer-disable-undo (current-buffer))
       (when (file-exists-p nnmail-message-id-cache-file)
        (nnheader-insert-file-contents nnmail-message-id-cache-file))
       (set-buffer-modified-p nil)
@@ -1510,9 +1521,9 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
     ;; Let the backend save the article (or not).
     (cond
      ((not duplication)
-      (nnmail-cache-insert message-id)
       (funcall func (setq group-art
-                         (nreverse (nnmail-article-group artnum-func)))))
+                         (nreverse (nnmail-article-group artnum-func))))
+      (nnmail-cache-insert message-id))
      ((eq action 'delete)
       (setq group-art nil))
      ((eq action 'warn)
@@ -1631,7 +1642,9 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
            ((numberp days)
             (setq days (days-to-time days))
             ;; Compare the time with the current time.
-            (time-less-p days (time-since time)))))))
+            (condition-case ()
+                (time-less-p days (time-since time))
+              (error nil)))))))
 
 (defvar nnmail-read-passwd nil)
 (defun nnmail-read-passwd (prompt &rest args)
@@ -1696,11 +1709,11 @@ If ARGS, PROMPT is used as an argument to `format'."
        (goto-char (point-min))
        (while (re-search-forward "[^ \t=]+" nil t)
          (setq name (match-string 0))
-         (if (not (= (following-char) ?=))
+         (if (not (eq (char-after) ?=))
              ;; Implied "yes".
              (setq value "yes")
            (forward-char 1)
-           (if (not (= (following-char) ?\"))
+           (if (not (eq (char-after) ?\"))
                (if (not (looking-at "[^ \t]"))
                    ;; Implied "no".
                    (setq value "no")
@@ -1763,7 +1776,11 @@ If ARGS, PROMPT is used as an argument to `format'."
 (defun nnmail-pop3-movemail (inbox crashbox)
   "Function to move mail from INBOX on a pop3 server to file CRASHBOX."
   (let ((pop3-maildrop
-         (substring inbox (match-end (string-match "^po:" inbox)))))
+         (substring inbox (match-end (string-match "^po:" inbox))))
+       (pop3-password
+        (or nnmail-pop-password
+            (nnmail-read-passwd
+             (format "Password for %s: " inbox)))))
     (pop3-movemail crashbox)))
 
 (defun nnmail-within-headers-p ()