(nnmaildir-request-set-mark): Add article to add-mark funcall.
[gnus] / lisp / nnimap.el
index e217ac5..a53f9ac 100644 (file)
@@ -303,6 +303,11 @@ textual parts.")
            (nnimap-send-command "NOOP")))))))
 
 (defun nnimap-open-connection (buffer)
+  ;; Be backwards-compatible -- the earlier value of nnimap-stream was
+  ;; `ssl' when nnimap-server-port was nil.  Sort of.
+  (when (and nnimap-server-port
+            (eq nnimap-stream 'undecided))
+    (setq nnimap-stream 'ssl))
   (let ((stream
         (if (eq nnimap-stream 'undecided)
             (loop for type in '(ssl network)
@@ -340,18 +345,20 @@ textual parts.")
              '("143" "993" "imap" "imaps"))
             (t
              (error "Unknown stream type: %s" nnimap-stream))))
-          connection-result login-result credentials)
+          (proto-stream-always-use-starttls t)
+           login-result credentials)
+      (when nnimap-server-port
+       (setq ports (append ports (list nnimap-server-port))))
       (destructuring-bind (stream greeting capabilities)
-         (open-proto-stream
+         (open-protocol-stream
           "*nnimap*" (current-buffer) nnimap-address (car (last ports))
           :type nnimap-stream
           :shell-command nnimap-shell-program
           :capability-command "1 CAPABILITY\r\n"
+          :success " OK "
           :starttls-function
           (lambda (capabilities)
-            (if (not (string-match "STARTTLS" capabilities))
-                ;; Not a STARTTLS-capable server.
-                nil
+            (when (gnus-string-match-p "STARTTLS" capabilities)
               "1 STARTTLS\r\n")))
        (setf (nnimap-process nnimap-object) stream)
        (if (not stream)
@@ -360,16 +367,14 @@ textual parts.")
                               nnimap-address port nnimap-stream)
              'no-connect)
          (gnus-set-process-query-on-exit-flag stream nil)
-         (if (not (string-match "[*.] OK" greeting))
+         (if (not (gnus-string-match-p "[*.] \\(OK\\|PREAUTH\\)" greeting))
              (nnheader-report 'nnimap "%s" greeting)
            ;; Store the greeting (for debugging purposes).
            (setf (nnimap-greeting nnimap-object) greeting)
            (setf (nnimap-capabilities nnimap-object)
                  (mapcar #'upcase
                          (split-string capabilities)))
-           (when nnimap-server-port
-             (push (format "%s" nnimap-server-port) ports))
-           (unless (equal connection-result "PREAUTH")
+           (unless (gnus-string-match-p "[*.] PREAUTH" greeting)
              (if (not (setq credentials
                             (if (eq nnimap-authenticator 'anonymous)
                                 (list "anonymous"