(nnimap-request-accept-article): Remove \n's from
[gnus] / lisp / nnimap.el
index fddc682..c9747a6 100644 (file)
@@ -54,6 +54,7 @@
 ;;     .newsrc.eld)
 ;;   o What about Gnus's article editing, can we support it?  NO!
 ;;   o Use \Draft to support the draft group??
+;;   o Duplicate suppression
 
 ;;; Code:
 
@@ -395,11 +396,12 @@ If EXAMINE is non-nil the group is selected read-only."
       (with-current-buffer nnimap-server-buffer
        (setq uid imap-current-message
              mbx imap-current-mailbox
-             headers (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 uid 'BODYDETAIL)))
-                       (imap-message-get uid 'RFC822.HEADER))
+             headers (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 uid 'BODYDETAIL)))
+                        (imap-message-get uid 'RFC822.HEADER)))
              lines (imap-body-lines (imap-message-body imap-current-message))
              chars (imap-message-get imap-current-message 'RFC822.SIZE)))
       (nnheader-insert-nov
@@ -458,13 +460,11 @@ If EXAMINE is non-nil the group is selected read-only."
       (when (file-exists-p nov)
        (mm-insert-file-contents nov)
        (set-buffer-modified-p nil)
-       (let ((min (progn (goto-char (point-min))
-                         (when (not (eobp))
-                           (read (current-buffer)))))
-             (max (progn (goto-char (point-max))
-                         (forward-line -1)
-                         (when (not (bobp))
-                           (read (current-buffer))))))
+       (let ((min (ignore-errors (goto-char (point-min))
+                                 (read (current-buffer))))
+             (max (ignore-errors (goto-char (point-max))
+                                 (forward-line -1)
+                                 (read (current-buffer)))))
          (if (and (numberp min) (numberp max))
              (cons min max)
            ;; junk, remove it, it's saved later
@@ -579,6 +579,8 @@ If EXAMINE is non-nil the group is selected read-only."
                      (cadr (assq 'nnimap-server-address defs))) defs)
        (push (list 'nnimap-address server) defs)))
     (nnoo-change-server 'nnimap server defs)
+    (with-current-buffer (get-buffer-create nnimap-server-buffer)
+      (nnoo-change-server 'nnimap server defs))
     (or (and nnimap-server-buffer
             (imap-opened nnimap-server-buffer))
        (nnimap-open-connection server))))
@@ -844,6 +846,18 @@ function is generally only called when Gnus is shutting down."
                      (gnus-info-marks info))
                     t)))
                gnus-article-mark-lists)
+
+       ;; 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 
+        (nnimap-update-alist-soft
+         'tick
+         (gnus-remove-from-range
+          (cdr-safe (assoc 'tick (gnus-info-marks info)))
+          (cdr-safe (assoc 'dormant (gnus-info-marks info))))
+         (gnus-info-marks info))
+        t)
        
        (gnus-message 5 "nnimap: Updating info for %s...done"
                      (gnus-info-group info))
@@ -1104,9 +1118,13 @@ function is generally only called when Gnus is shutting down."
                                             nnimap-current-move-article)
                                            group 'dontcreate nil
                                            nnimap-server-buffer))
-                 ;; turn into rfc822 format (\r\n eol's)
                  (with-current-buffer (current-buffer)
                    (goto-char (point-min))
+                   ;; remove any 'From blabla' lines, some IMAP servers
+                   ;; reject the entire message otherwise.
+                   (when (looking-at "^From[^:]")
+                     (kill-region (point) (progn (forward-line) (point))))
+                   ;; turn into rfc822 format (\r\n eol's)
                    (while (search-forward "\n" nil t)
                      (replace-match "\r\n")))
                   ;; this 'or' is for Cyrus server bug
@@ -1136,7 +1154,8 @@ function is generally only called when Gnus is shutting down."
 
 (defun nnimap-acl-get (mailbox server)
   (when (nnimap-possibly-change-server server)
-    (imap-mailbox-acl-get mailbox nnimap-server-buffer)))
+    (and (imap-capability 'ACL nnimap-server-buffer)
+        (imap-mailbox-acl-get mailbox nnimap-server-buffer))))
 
 (defun nnimap-acl-edit (mailbox method old-acls new-acls)
   (when (nnimap-possibly-change-server (cadr method))