Revert "Add recent argument to nnimap-find-article-by-message-id"
authorDave Abrahams <dave@boostpro.com>
Tue, 28 Aug 2012 19:34:49 +0000 (12:34 -0700)
committerDave Abrahams <dave@boostpro.com>
Wed, 29 Aug 2012 17:48:11 +0000 (10:48 -0700)
This reverts commit ac8ce21091b89a7a05ad821854f4d3e7ff35a394.

Conflicts:

lisp/ChangeLog
lisp/nnimap.el

lisp/nnimap.el

index b544ae8..970e6b4 100644 (file)
@@ -980,31 +980,21 @@ textual parts.")
                               (cdr (assoc "SEARCH" (cdr result))))))))))
 
 
-(defun nnimap-find-article-by-message-id (group server message-id &optional limit)
-  "Search for message with MESSAGE-ID in GROUP from SERVER.
-If LIMIT, first try to limit the search to the N last articles."
+(defun nnimap-find-article-by-message-id (group server message-id)
+  "Search for message with MESSAGE-ID in GROUP from SERVER."
   (with-current-buffer (nnimap-buffer)
     (erase-buffer)
-    (let* ((number-of-article
-           (catch 'found
-             (dolist (result (cdr (nnimap-change-group group server nil t)))
-               (when (equal "EXISTS" (cadr result))
-                 (throw 'found (car result))))))
-           (sequence
-            (nnimap-send-command "UID SEARCH%s HEADER Message-Id %S"
-                                 (if (and limit number-of-article)
-                                     ;; The -1 is because IMAP message
-                                     ;; numbers are one-based rather than
-                                     ;; zero-based.
-                                     (format " %s:*" (- (string-to-number number-of-article) limit -1))
-                                   "")
-                                 message-id)))
-      (when (nnimap-wait-for-response sequence)
-        (let ((article (car (last (cdr (assoc "SEARCH" (nnimap-parse-response)))))))
-          (if article
-              (string-to-number article)
-            (when (and limit number-of-article)
-              (nnimap-find-article-by-message-id group server message-id))))))))
+    (nnimap-change-group group server nil t)
+    (let ((sequence
+          (nnimap-send-command "UID SEARCH HEADER Message-Id %S" message-id))
+         article result)
+      (setq result (nnimap-wait-for-response sequence))
+      (when (and result
+                (car (setq result (nnimap-parse-response))))
+       ;; Select the last instance of the message in the group.
+       (and (setq article
+                  (car (last (cdr (assoc "SEARCH" (cdr result))))))
+            (string-to-number article))))))
 
 (defun nnimap-delete-article (articles)
   (with-current-buffer (nnimap-buffer)