Refresh redirect.
[gnus] / lisp / nnimap.el
index 83ef201..af1de33 100644 (file)
@@ -1,5 +1,5 @@
 ;;; nnimap.el --- imap backend for Gnus
-;; Copyright (C) 1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <jas@pdc.kth.se>
 ;;         Jim Radford <radford@robby.caltech.edu>
@@ -126,6 +126,13 @@ This variable can also have a function as its value, the function will
 be called with the headers narrowed and should return a group where it
 thinks the article should be splitted to.")
 
+(defvar nnimap-split-predicate "UNSEEN UNDELETED"
+  "The predicate used to find articles to split.
+If you use another IMAP client to peek on articles but always would
+like nnimap to split them once it's started, you could change this to
+\"UNDELETED\". Other available predicates are available in
+RFC2060 section 6.4.4.")
+
 (defvar nnimap-split-fancy nil
   "Like `nnmail-split-fancy', which see.")
 
@@ -377,6 +384,8 @@ If EXAMINE is non-nil the group is selected read-only."
         (buffer-disable-undo)
         (insert headers)
         (nnheader-ms-strip-cr)
+        (nnheader-fold-continuation-lines)
+        (subst-char-in-region (point-min) (point-max) ?\t ? )
         (let ((head (nnheader-parse-head 'naked)))
           (mail-header-set-number head uid)
           (mail-header-set-chars head chars)
@@ -493,8 +502,8 @@ If EXAMINE is non-nil the group is selected read-only."
                     (cons (1+ (cdr cached)) high) group server))
                  (when nnimap-prune-cache
                    ;; remove nov's for articles which has expired on server
-                    (goto-char (point-min))
-                    (dolist (uid (gnus-set-difference articles uids))
+                   (goto-char (point-min))
+                   (dolist (uid (gnus-set-difference articles uids))
                       (when (re-search-forward (format "^%d\t" uid) nil t)
                         (gnus-delete-line)))))
              ;; nothing cached, fetch whole range from server
@@ -605,8 +614,8 @@ function is generally only called when Gnus is shutting down."
     (nnheader-ms-strip-cr)
     (funcall nnimap-callback-callback-function t)))
 
-(defun nnimap-request-article-part (article part prop
-                                           &optional group server to-buffer)
+(defun nnimap-request-article-part (article part prop &optional
+                                            group server to-buffer detail)
   (when (nnimap-possibly-change-group group server)
     (let ((article (if (stringp article)
                       (car-safe (imap-search
@@ -618,9 +627,12 @@ function is generally only called when Gnus is shutting down."
        (if (not nnheader-callback-function)
            (with-current-buffer (or to-buffer nntp-server-buffer)
              (erase-buffer)
-             (insert (nnimap-demule (imap-fetch article part prop nil
-                                                nnimap-server-buffer)))
-             (nnheader-ms-strip-cr)
+              (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 9 "nnimap: Fetching (part of) article %d...done"
                            article)
              (if (bobp)
@@ -637,16 +649,25 @@ function is generally only called when Gnus is shutting down."
   t)
 
 (deffoo nnimap-request-article (article &optional group server to-buffer)
-  (nnimap-request-article-part
-   article "RFC822.PEEK" 'RFC822 group server to-buffer))
+  (if (imap-capability 'IMAP4rev1 nnimap-server-buffer)
+      (nnimap-request-article-part
+       article "BODY.PEEK[]" 'BODYDETAIL group server to-buffer 'detail)
+    (nnimap-request-article-part
+     article "RFC822.PEEK" 'RFC822 group server to-buffer)))
 
 (deffoo nnimap-request-head (article &optional group server to-buffer)
-  (nnimap-request-article-part
-   article "RFC822.HEADER" 'RFC822.HEADER group server to-buffer))
+  (if (imap-capability 'IMAP4rev1 nnimap-server-buffer)
+      (nnimap-request-article-part
+       article "BODY.PEEK[HEADER]" 'BODYDETAIL group server to-buffer 'detail)
+    (nnimap-request-article-part
+     article "RFC822.HEADER" 'RFC822.HEADER group server to-buffer)))
 
 (deffoo nnimap-request-body (article &optional group server to-buffer)
-  (nnimap-request-article-part
-   article "RFC822.TEXT.PEEK" 'RFC822.TEXT group server to-buffer))
+  (if (imap-capability 'IMAP4rev1 nnimap-server-buffer)
+      (nnimap-request-article-part
+       article "BODY.PEEK[TEXT]" 'BODYDETAIL group server to-buffer 'detail)
+    (nnimap-request-article-part
+     article "RFC822.TEXT.PEEK" 'RFC822.TEXT group server to-buffer)))
 
 (deffoo nnimap-request-group (group &optional server fast)
   (nnimap-request-update-info-internal
@@ -892,7 +913,7 @@ function is generally only called when Gnus is shutting down."
          ;; find split rule for this server / inbox
          (when (setq rule (nnimap-split-find-rule server inbox))
            ;; iterate over articles
-           (dolist (article (imap-search "UNSEEN UNDELETED"))
+           (dolist (article (imap-search nnimap-split-predicate))
              (when (nnimap-request-head article)
                ;; copy article to right group(s)
                (setq removeorig nil)