Indent.
[gnus] / lisp / nnimap.el
index 0aaa797..8dad44d 100644 (file)
@@ -316,15 +316,19 @@ textual parts.")
                   (setq port (or nnimap-server-port "imap"))
                   'starttls))
                '("imap"))
-              ((eq nnimap-stream 'ssl)
-               (open-tls-stream
-                "*nnimap*" (current-buffer) nnimap-address
-                (setq port
-                      (or nnimap-server-port
-                          (if (netrc-find-service-number "imaps")
-                              "imaps"
-                            "993"))))
-               '("143" "993" "imap" "imaps"))))
+              ((memq nnimap-stream '(ssl tls))
+               (funcall (if (fboundp 'open-gnutls-stream)
+                            'open-gnutls-stream
+                          'open-tls-stream)
+                        "*nnimap*" (current-buffer) nnimap-address
+                        (setq port
+                              (or nnimap-server-port
+                                  (if (netrc-find-service-number "imaps")
+                                      "imaps"
+                                    "993"))))
+               '("143" "993" "imap" "imaps"))
+              (t
+               (error "Unknown stream type: %s" nnimap-stream))))
             connection-result login-result credentials)
        (setf (nnimap-process nnimap-object)
              (get-buffer-process (current-buffer)))
@@ -333,7 +337,8 @@ textual parts.")
                            '(open run))))
            (nnheader-report 'nnimap "Unable to contact %s:%s via %s"
                             nnimap-address port nnimap-stream)
-         (gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil)
+         (gnus-set-process-query-on-exit-flag
+          (nnimap-process nnimap-object) nil)
          (if (not (setq connection-result (nnimap-wait-for-connection)))
              (nnheader-report 'nnimap
                               "%s" (buffer-substring
@@ -424,7 +429,10 @@ textual parts.")
     result))
 
 (deffoo nnimap-close-server (&optional server)
-  t)
+  (when (nnoo-change-server 'nnimap server nil)
+    (ignore-errors
+      (delete-process (get-buffer-process (nnimap-buffer))))
+    t))
 
 (deffoo nnimap-request-close ()
   t)
@@ -644,6 +652,12 @@ textual parts.")
     (with-current-buffer (nnimap-buffer)
       (car (nnimap-command "DELETE %S" (utf7-encode group t))))))
 
+(deffoo nnimap-request-rename-group (group new-name &optional server)
+  (when (nnimap-possibly-change-group nil server)
+    (with-current-buffer (nnimap-buffer)
+      (car (nnimap-command "RENAME %S %S"
+                          (utf7-encode group t) (utf7-encode new-name t))))))
+
 (deffoo nnimap-request-expunge-group (group &optional server)
   (when (nnimap-possibly-change-group group server)
     (with-current-buffer (nnimap-buffer)
@@ -921,7 +935,8 @@ textual parts.")
                     (nnimap-get-groups)))
       (unless (assoc group nnimap-current-infos)
        ;; Insert dummy numbers here -- they don't matter.
-       (insert (format "%S 0 1 y\n" group))))))
+       (insert (format "%S 0 1 y\n" group))))
+    t))
 
 (deffoo nnimap-retrieve-group-data-early (server infos)
   (when (nnimap-possibly-change-group nil server)
@@ -974,7 +989,7 @@ textual parts.")
             (nnimap-possibly-change-group nil server))
     (with-current-buffer (nnimap-buffer)
       ;; Wait for the final data to trickle in.
-      (when (nnimap-wait-for-response (cadar sequences))
+      (when (nnimap-wait-for-response (cadar sequences) t)
        ;; Now we should have all the data we need, no matter whether
        ;; we're QRESYNCING, fetching all the flags from scratch, or
        ;; just fetching the last 100 flags per group.
@@ -1002,8 +1017,10 @@ textual parts.")
 
 (defun nnimap-update-info (info marks)
   (when (and marks
-            ;; Ignore groups with no UIDNEXT values.
-            (nth 4 marks))
+            ;; Ignore groups with no UIDNEXT/marks.  This happens for
+            ;; completely empty groups.
+            (or (car marks)
+                (nth 4 marks)))
     (destructuring-bind (existing flags high low uidnext start-article
                                  permanent-flags) marks
       (let ((group (gnus-info-group info))
@@ -1030,9 +1047,6 @@ textual parts.")
           group
           (cons (car (gnus-active group))
                 (or high (1- uidnext)))))
-       (when (and (not high)
-                  uidnext)
-         (setq high (1- uidnext)))
        ;; Then update the list of read articles.
        (let* ((unread
                (gnus-compress-sequence
@@ -1251,7 +1265,7 @@ textual parts.")
                        (point-min))
                      t)))
       (when messagep
-       (message "Read %dKB" (/ (buffer-size) 1000)))
+       (message "nnimap read %dk" (/ (buffer-size) 1000)))
       (nnheader-accept-process-output process)
       (goto-char (point-max)))
     openp))
@@ -1280,13 +1294,15 @@ textual parts.")
          (push
           (cond
            ((eql char ?\[)
-            (split-string (buffer-substring
-                           (1+ (point))
-                           (1- (search-forward "]" (line-end-position) 'move)))))
+            (split-string
+             (buffer-substring
+              (1+ (point))
+              (1- (search-forward "]" (line-end-position) 'move)))))
            ((eql char ?\()
-            (split-string (buffer-substring
-                           (1+ (point))
-                           (1- (search-forward ")" (line-end-position) 'move)))))
+            (split-string
+             (buffer-substring
+              (1+ (point))
+              (1- (search-forward ")" (line-end-position) 'move)))))
            ((eql char ?\")
             (forward-char 1)
             (buffer-substring