Merge changes made in Gnus trunk.
[bpt/emacs.git] / lisp / gnus / nnimap.el
index 3fbcef6..bb9f569 100644 (file)
@@ -304,6 +304,7 @@ textual parts.")
               ((or (eq nnimap-stream 'network)
                    (and (eq nnimap-stream 'starttls)
                         (fboundp 'open-gnutls-stream)))
+               (message "Opening connection to %s..." nnimap-address)
                (open-network-stream
                 "*nnimap*" (current-buffer) nnimap-address
                 (setq port
@@ -313,18 +314,22 @@ textual parts.")
                             "143"))))
                '("143" "imap"))
               ((eq nnimap-stream 'shell)
+               (message "Opening connection to %s via shell..." nnimap-address)
                (nnimap-open-shell-stream
                 "*nnimap*" (current-buffer) nnimap-address
                 (setq port (or nnimap-server-port "imap")))
                '("imap"))
               ((eq nnimap-stream 'starttls)
+               (message "Opening connection to %s via starttls..."
+                        nnimap-address)
                (let ((tls-program
-                      '("openssl s_client %s -connect %h:%p -no_ssl2 -ign_eof -starttls imap")))
+                      '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof -starttls imap")))
                  (open-tls-stream
                   "*nnimap*" (current-buffer) nnimap-address
                   (setq port (or nnimap-server-port "imap"))))
                '("imap"))
               ((memq nnimap-stream '(ssl tls))
+               (message "Opening connection to %s via tls..." nnimap-address)
                (funcall (if (fboundp 'open-gnutls-stream)
                             'open-gnutls-stream
                           'open-tls-stream)
@@ -1311,6 +1316,25 @@ textual parts.")
   (setq nnimap-status-string "Read-only server")
   nil)
 
+(deffoo nnimap-request-thread (id)
+    (let* ((refs (split-string
+              (or (mail-header-references (gnus-summary-article-header))
+                  "")))
+          (cmd (let ((value
+                      (format
+                       "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
+                       id id)))
+                 (dolist (refid refs value)
+                   (setq value (format
+                                "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
+                                refid refid value)))))
+          (result
+           (with-current-buffer (nnimap-buffer)
+             (nnimap-command  "UID SEARCH %s" cmd))))
+      (gnus-fetch-headers (and (car result)
+          (delete 0 (mapcar #'string-to-number
+                            (cdr (assoc "SEARCH" (cdr result)))))))))
+
 (defun nnimap-possibly-change-group (group server)
   (let ((open-result t))
     (when (and server