emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/gnus-select2 f3fd674 06/32: Restore article retrie


From: Andrew G Cohen
Subject: [Emacs-diffs] feature/gnus-select2 f3fd674 06/32: Restore article retrieval by message-id in nnselect
Date: Sun, 16 Dec 2018 06:54:01 -0500 (EST)

branch: feature/gnus-select2
commit f3fd674639c85d0ba8bd1ae5376d91c00222a3e6
Author: Andrew G Cohen <address@hidden>
Commit: Andrew G Cohen <address@hidden>

    Restore article retrieval by message-id in nnselect
    
    * lisp/gnus/nnselect.el (nnselect-request-article): If passed a
    message-id attempt to find an article by searching.
---
 lisp/gnus/nnselect.el | 75 ++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 63 insertions(+), 12 deletions(-)

diff --git a/lisp/gnus/nnselect.el b/lisp/gnus/nnselect.el
index 095597a..f0df535 100644
--- a/lisp/gnus/nnselect.el
+++ b/lisp/gnus/nnselect.el
@@ -269,18 +269,69 @@ If this variable is nil, or if the provided function 
returns nil,
   ;; We shoud only arrive here if we are in an nnselect group and we
   ;; are requesting a real article. Just find the originating
   ;; group for the article and pass the request on.
-  (when (numberp article)
-    (unless (zerop (nnselect-artlist-length nnselect-artlist))
-      (let ((artgroup (nnselect-article-group article))
-           (artnumber (nnselect-article-number article)))
-       (message "Requesting article %d from group %s"
-                artnumber artgroup)
-       (if to-buffer
-           (with-current-buffer to-buffer
-             (let ((gnus-article-decode-hook nil))
-               (gnus-request-article-this-buffer artnumber artgroup)))
-         (gnus-request-article artnumber artgroup))
-       (cons artgroup artnumber)))))
+  (if (numberp article)
+      (unless (zerop (nnselect-artlist-length nnselect-artlist))
+       (let ((artgroup (nnselect-article-group article))
+             (artnumber (nnselect-article-number article)))
+         (message "Requesting article %d from group %s"
+                  artnumber artgroup)
+         (if to-buffer
+             (with-current-buffer to-buffer
+               (let ((gnus-article-decode-hook nil))
+                 (gnus-request-article-this-buffer artnumber artgroup)))
+           (gnus-request-article artnumber artgroup))
+         (cons artgroup artnumber)))
+    (let (articleno)
+      (save-excursion
+        ;; if we are coming from an nnimap group we can search the
+        ;; whole server. Its usually so fast we might as well. If we
+        ;; want we could make this configurable.
+        (when (eq 'nnimap (car (gnus-server-to-method server)))
+          (let ((article article)
+               (gnus-override-method (gnus-server-to-method server))
+                query)
+            (setq query
+                  (list
+                   (cons 'query (format "HEADER Message-ID %s" article))
+                   (cons 'criteria "")
+                   (cons 'shortcut t)))
+            (setq nnselect-artlist (nnir-run-imap query server))
+            (setq articleno 1)))
+        (when to-buffer
+          (set-buffer to-buffer))
+        (let* ((gnus-override-method nil)
+               ;; We try the obvious---if we found the article above,
+               ;; or if its a real article we are done. Otherwise see
+               ;; where other articles in the thread come from.
+               (articleno
+                (or articleno
+                    (with-current-buffer gnus-summary-buffer
+                      (if (> (gnus-summary-article-number) 0)
+                          (gnus-summary-article-number)
+                        (let ((thread  (gnus-id-to-thread article)))
+                          (when thread
+                            (cl-some #'(lambda (x)
+                                         (when (and x (> x 0)) x))
+                                     (gnus-articles-in-thread thread))))))))
+              ;; now we have to request the article. if we are coming
+               ;; from nnselect then we have an nnselect-artlist and we look
+               ;; up the originating group for whatever article we
+               ;; found in the previous section. if not we try to look
+               ;; up a server or group method and retrieve the
+               ;; original article id that way.
+
+              ;; (gnus-command-method
+               ;; (gnus-find-method-for-group (when (not (zerop
+               ;; (nnir-artlist-length nnir-artlist)))
+               ;; (nnir-article-group (or articleno 1))))))
+              (gnus-command-method
+               (if (zerop (nnselect-artlist-length nnselect-artlist))
+                   (or (gnus-server-to-method server)
+                       (gnus-find-method-for-group group))
+                 (gnus-find-method-for-group
+                  (nnselect-article-group (or articleno 1))))))
+          (funcall (gnus-get-function gnus-command-method 'request-article)
+                   article nil (nth 1 gnus-command-method) to-buffer))))))
 
 
 (deffoo nnselect-request-move-article (article group server accept-form



reply via email to

[Prev in Thread] Current Thread [Next in Thread]