From: Andrew G Cohen Date: Tue, 25 Apr 2017 05:10:41 +0000 (+0800) Subject: Restore article retrieval by message-id in nnselect X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f3fd674639c85d0ba8bd1ae5376d91c00222a3e6;p=emacs.git 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. --- diff --git a/lisp/gnus/nnselect.el b/lisp/gnus/nnselect.el index 095597a3243..f0df5357840 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