* texi/gnus-ja.texi (Article Date): Update Japanese translation.
[elisp/gnus.git-] / lisp / nnimap.el
index a5bd4d4..6740e65 100644 (file)
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+(eval-when-compile (require 'gnus-clfns))
 (require 'imap)
+
 (require 'nnoo)
 (require 'nnmail)
 (require 'nnheader)
-(require 'mm-util)
 (require 'gnus)
 (require 'gnus-range)
 (require 'gnus-start)
@@ -172,7 +174,7 @@ group/function elements."
                         (nnimap-strict-function :tag "User-defined function"))
                 (repeat :menu-tag "Multi-server (extended)"
                         :tag "Multi-server list"
-                        (list (regexp :tag "Server regexp") 
+                        (list (regexp :tag "Server regexp")
                               (list (regexp :tag "Incoming Mailbox regexp")
                                     (repeat :tag "Rules for matching server(s) and mailbox(es)"
                                             (list (string :tag "Destination mailbox")
@@ -366,8 +368,8 @@ For example: (setq nnimap-debug \"*nnimap-debug*\")")
 (defvar nnimap-callback-buffer nil
   "Which buffer the asynchronous article prefetch callback should work in.")
 (defvar nnimap-server-buffer-alist nil)        ;; Map server name to buffers.
-(defvar nnimap-current-server nil) ;; Current server
-(defvar nnimap-server-buffer nil) ;; Current servers' buffer
+(defvar nnimap-current-server nil)     ;; Current server
+(defvar nnimap-server-buffer nil)      ;; Current servers' buffer
 
 \f
 
@@ -398,12 +400,12 @@ If SERVER is nil, uses the current server."
                           (if (equal server "")
                               "unnamed"
                             server) "." group "." old-uidvalidity
-                          nnimap-nov-file-name-suffix) t))
+                            nnimap-nov-file-name-suffix) t))
         (file (if (or nnmail-use-long-file-names
                       (file-exists-p (expand-file-name nameuid dir)))
                   (expand-file-name nameuid dir)
                 (expand-file-name
-                 (mm-encode-coding-string
+                 (encode-coding-string
                   (nnheader-replace-chars-in-string nameuid ?. ?/)
                   nnmail-pathname-coding-system)
                  dir))))
@@ -449,7 +451,7 @@ If EXAMINE is non-nil the group is selected read-only."
                     group (or server nnimap-current-server))
                    (zerop (imap-mailbox-get 'exists group))
                    t ;; for OGnus to see if ignoring uidvalidity
-                   ;; changes has any bad effects.
+                     ;; changes has any bad effects.
                    (yes-or-no-p
                     (format
                      "nnimap: Group %s is not uidvalid.  Continue? " group)))
@@ -495,6 +497,8 @@ If EXAMINE is non-nil the group is selected read-only."
        (with-temp-buffer
         (buffer-disable-undo)
         (insert headers)
+        (nnheader-fold-continuation-lines)
+        (subst-char-in-region (point-min) (point-max) ?\t ? )
         (nnheader-ms-strip-cr)
         (nnheader-fold-continuation-lines)
         (subst-char-in-region (point-min) (point-max) ?\t ? )
@@ -544,12 +548,12 @@ If EXAMINE is non-nil the group is selected read-only."
                           (if (equal server "")
                               "unnamed"
                             server) "." group "." uidvalidity
-                          nnimap-nov-file-name-suffix) t))
+                            nnimap-nov-file-name-suffix) t))
         (oldfile (if (or nnmail-use-long-file-names
                          (file-exists-p (expand-file-name name dir)))
                      (expand-file-name name dir)
                    (expand-file-name
-                    (mm-encode-coding-string
+                    (encode-coding-string
                      (nnheader-replace-chars-in-string name ?. ?/)
                      nnmail-pathname-coding-system)
                     dir)))
@@ -557,7 +561,7 @@ If EXAMINE is non-nil the group is selected read-only."
                          (file-exists-p (expand-file-name nameuid dir)))
                      (expand-file-name nameuid dir)
                    (expand-file-name
-                    (mm-encode-coding-string
+                    (encode-coding-string
                      (nnheader-replace-chars-in-string nameuid ?. ?/)
                      nnmail-pathname-coding-system)
                     dir))))
@@ -575,7 +579,7 @@ If EXAMINE is non-nil the group is selected read-only."
   (with-current-buffer nntp-server-buffer
     (let ((nov (nnimap-group-overview-filename group server)))
       (when (file-exists-p nov)
-       (mm-insert-file-contents nov)
+       (nnheader-insert-file-contents nov)
        (set-buffer-modified-p nil)
        (let ((min (ignore-errors (goto-char (point-min))
                                  (read (current-buffer))))
@@ -641,7 +645,7 @@ If EXAMINE is non-nil the group is selected read-only."
                    (nnimap-retrieve-headers-from-server
                     (cons (1+ (cdr cached)) high) group server))
                  (when nnimap-prune-cache
-             ;; remove nov's for articles which has expired on server
+                   ;; remove nov's for articles which has expired on server
                    (goto-char (point-min))
                    (dolist (uid (gnus-set-difference articles uids))
                      (when (re-search-forward (format "^%d\t" uid) nil t)
@@ -754,12 +758,11 @@ function is generally only called when Gnus is shutting down."
   (with-current-buffer nnimap-callback-buffer
     (insert
      (with-current-buffer nnimap-server-buffer
-       (nnimap-demule
-       (if (imap-capability 'IMAP4rev1)
-           ;; xxx don't just use car? alist doesn't contain
-           ;; anything else now, but it might...
-           (nth 2 (car (imap-message-get (imap-current-message) 'BODYDETAIL)))
-         (imap-message-get (imap-current-message) 'RFC822)))))
+       (if (imap-capability 'IMAP4rev1)
+          ;; xxx don't just use car? alist doesn't contain
+          ;; anything else now, but it might...
+          (nth 2 (car (imap-message-get (imap-current-message) 'BODYDETAIL)))
+        (imap-message-get (imap-current-message) 'RFC822))))
     (nnheader-ms-strip-cr)
     (funcall nnimap-callback-callback-function t)))
 
@@ -778,16 +781,16 @@ function is generally only called when Gnus is shutting down."
              (erase-buffer)
              (let ((data (imap-fetch article part prop nil
                                      nnimap-server-buffer)))
-               (insert (nnimap-demule (if detail
-                                          (nth 2 (car data))
-                                        data))))
-             (nnheader-ms-strip-cr)
-             (gnus-message 10 "nnimap: Fetching (part of) article %d...done"
-                           article)
-             (if (bobp)
-                 (nnheader-report 'nnimap "No such article: %s"
-                                  (imap-error-text nnimap-server-buffer))
-               (cons group article)))
+               (when data
+                 (insert (if detail (nth 2 (car data)) data))
+                 (nnheader-ms-strip-cr)
+                 (gnus-message 10
+                               "nnimap: Fetching (part of) article %d...done"
+                               article)
+                 (if (bobp)
+                     (nnheader-report 'nnimap "No such article: %s"
+                                      (imap-error-text nnimap-server-buffer))
+                   (cons group article)))))
          (add-hook 'imap-fetch-data-hook 'nnimap-callback)
          (setq nnimap-callback-callback-function nnheader-callback-function
                nnimap-callback-buffer nntp-server-buffer)
@@ -917,7 +920,7 @@ function is generally only called when Gnus is shutting down."
        (or (member "\\NoSelect"
                    (imap-mailbox-get 'list-flags group nnimap-server-buffer))
            (let ((info (nnimap-find-minmax-uid group 'examine)))
-             (when (> (or (imap-mailbox-get 'recent group 
+             (when (> (or (imap-mailbox-get 'recent group
                                             nnimap-server-buffer) 0)
                       0)
                (push (list (cons group 0)) nnmail-split-history))
@@ -929,7 +932,7 @@ function is generally only called when Gnus is shutting down."
 
 (deffoo nnimap-request-update-info-internal (group info &optional server)
   (when (nnimap-possibly-change-group group server)
-    (when info ;; xxx what does this mean? should we create a info?
+    (when info;; xxx what does this mean? should we create a info?
       (with-current-buffer nnimap-server-buffer
        (gnus-message 5 "nnimap: Updating info for %s..."
                      (gnus-info-group info))
@@ -972,7 +975,7 @@ function is generally only called when Gnus is shutting down."
                gnus-article-mark-lists)
 
        (when nnimap-importantize-dormant
-      ;; nnimap mark dormant article as ticked too (for other clients)
+         ;; nnimap mark dormant article as ticked too (for other clients)
          ;; so we remove that mark for gnus since we support dormant
          (gnus-info-set-marks
           info
@@ -1068,7 +1071,7 @@ function is generally only called when Gnus is shutting down."
                               (setq regrepp (string-match "\\\\[0-9&]" group))
                               (re-search-forward regexp nil t))
                           (funcall regexp group))
-                ;; Don't enter the article into the same group twice.
+                        ;; Don't enter the article into the same group twice.
                         (not (assoc group to-groups)))
                (push (if regrepp
                          (nnmail-expand-newtext group)
@@ -1104,7 +1107,7 @@ function is generally only called when Gnus is shutting down."
       (let (rule inbox removeorig (inboxes (nnimap-split-find-inbox server)))
        ;; iterate over inboxes
        (while (and (setq inbox (pop inboxes))
-                   (nnimap-possibly-change-group inbox)) ;; SELECT
+                   (nnimap-possibly-change-group inbox));; SELECT
          ;; find split rule for this server / inbox
          (when (setq rule (nnimap-split-find-rule server inbox))
            ;; iterate over articles
@@ -1131,7 +1134,7 @@ function is generally only called when Gnus is shutting down."
                (and removeorig
                     (imap-message-flags-add (format "%d" article)
                                             "\\Seen \\Deleted")))))
-         (when (imap-mailbox-select inbox) ;; just in case
+         (when (imap-mailbox-select inbox);; just in case
            ;; todo: UID EXPUNGE (if available) to remove splitted articles
            (imap-mailbox-expunge)
            (imap-mailbox-close)))
@@ -1200,7 +1203,7 @@ function is generally only called when Gnus is shutting down."
   (unless (eq nnmail-expiry-target 'delete)
     (with-temp-buffer
       (dolist (art (gnus-uncompress-sequence arts))
-       (nnimap-request-article art group server  (current-buffer))
+       (nnimap-request-article art group server (current-buffer))
        ;; hints for optimization in `nnimap-request-accept-article'
        (let ((nnimap-current-move-article art)
              (nnimap-current-move-group group)
@@ -1274,7 +1277,7 @@ function is generally only called when Gnus is shutting down."
     (let (uid)
       (if (setq uid
                (if (string= nnimap-current-server nnimap-current-move-server)
-                 ;; moving article within same server, speed it up...
+                   ;; moving article within same server, speed it up...
                    (and (nnimap-possibly-change-group
                          nnimap-current-move-group)
                         (imap-message-copy (number-to-string
@@ -1283,7 +1286,7 @@ function is generally only called when Gnus is shutting down."
                                            nnimap-server-buffer))
                  (with-current-buffer (current-buffer)
                    (goto-char (point-min))
-                 ;; remove any 'From blabla' lines, some IMAP servers
+                   ;; remove any 'From blabla' lines, some IMAP servers
                    ;; reject the entire message otherwise.
                    (when (looking-at "^From[^:]")
                      (kill-region (point) (progn (forward-line) (point))))