From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/73035 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: A T does not work in nnimap Date: Tue, 12 Oct 2010 19:43:11 -0400 Message-ID: <87mxqjvuy8.fsf@andy.bu.edu> References: <874ocrwjxu.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1286927052 27030 80.91.229.12 (12 Oct 2010 23:44:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 12 Oct 2010 23:44:12 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21407@lists.math.uh.edu Wed Oct 13 01:44:11 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P5oVs-00023L-Oq for ding-account@gmane.org; Wed, 13 Oct 2010 01:44:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1P5oVF-0005BH-FL; Tue, 12 Oct 2010 18:43:29 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1P5oVD-0005Az-9z for ding@lists.math.uh.edu; Tue, 12 Oct 2010 18:43:27 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P5oV7-0003Gp-Qi for ding@lists.math.uh.edu; Tue, 12 Oct 2010 18:43:27 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P5oV7-0004lL-00 for ; Wed, 13 Oct 2010 01:43:21 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P5oV6-0001qQ-VG for ding@gnus.org; Wed, 13 Oct 2010 01:43:20 +0200 Original-Received: from andy.bu.edu ([128.197.41.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 13 Oct 2010 01:43:20 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 13 Oct 2010 01:43:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 180 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: andy.bu.edu User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:4rRNdzgoW0dPV+UHsolEGdAY0Mw= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:73035 Archived-At: --=-=-= Content-Type: text/plain OK here is a first pass at modifying gnus-summary-refer-thread to work with imap. It seemed like a good idea to factor out a thread-searching function for nnimap, so I did. Only lightly tested. Regards, Andy --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=changes.diff Content-Description: imap threading changes diff --git a/lisp/nnir.el b/lisp/nnir.el index 2a264d1..2dcebe6 100644 --- a/lisp/nnir.el +++ b/lisp/nnir.el @@ -343,7 +343,8 @@ (eval-when-compile (autoload 'nnimap-buffer "nnimap") (autoload 'nnimap-command "nnimap") - (autoload 'nnimap-possibly-change-group "nnimap")) + (autoload 'nnimap-possibly-change-group "nnimap") + (autoload 'nnimap-find-thread "nnimap")) (nnoo-declare nnir) (nnoo-define-basics nnir) @@ -717,21 +718,8 @@ and show thread that contains this article." (refs (split-string (mail-header-references (gnus-summary-article-header))))) (if (string= (car (gnus-group-method group)) "nnimap") - (with-current-buffer (nnimap-buffer) - (let* ((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 (nnimap-command - "UID SEARCH %s" cmd))) - (gnus-summary-read-group-1 group t t gnus-summary-buffer nil - (and (car result) - (delete 0 (mapcar #'string-to-number - (cdr (assoc "SEARCH" (cdr result))))))))) + (gnus-summary-read-group-1 group t t gnus-summary-buffer nil + (nnimap-find-thread id refs)) (gnus-summary-read-group-1 group t t gnus-summary-buffer nil (list backend-number)) (gnus-summary-limit (list backend-number)) diff --git a/lisp/nnimap.el b/lisp/nnimap.el index c6c8787..5de8518 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -1659,6 +1659,22 @@ textual parts.") group-art)) nnimap-incoming-split-list))) +(defun nnimap-find-thread (id refs) + (let* ((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)))) + (and (car result) + (delete 0 (mapcar #'string-to-number + (cdr (assoc "SEARCH" (cdr result)))))))) + (provide 'nnimap) ;;; nnimap.el ends here diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 1086e28..a2f7a90 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -60,6 +60,7 @@ (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t) (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t) (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t) +(autoload 'nnimap-find-thread "nnimap") (defcustom gnus-kill-summary-on-exit t "*If non-nil, kill the summary buffer when you exit from it. @@ -8828,28 +8829,35 @@ If LIMIT (the numerical prefix), fetch that many old headers instead of what's specified by the `gnus-refer-thread-limit' variable." (interactive "P") (let ((id (mail-header-id (gnus-summary-article-header))) + (refs (split-string (or + (mail-header-references (gnus-summary-article-header)) ""))) (limit (if limit (prefix-numeric-value limit) gnus-refer-thread-limit))) - (unless (eq gnus-fetch-old-headers 'invisible) - (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) - ;; Retrieve the headers and read them in. - (if (eq (if (numberp limit) - (gnus-retrieve-headers - (list (min - (+ (mail-header-number - (gnus-summary-article-header)) - limit) - gnus-newsgroup-end)) - gnus-newsgroup-name (* limit 2)) - ;; gnus-refer-thread-limit is t, i.e. fetch _all_ - ;; headers. - (gnus-retrieve-headers (list gnus-newsgroup-end) - gnus-newsgroup-name limit)) - 'nov) - (gnus-build-all-threads) - (error "Can't fetch thread from back ends that don't support NOV")) - (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)) - (gnus-summary-limit-include-thread id))) + (if (string= (car (gnus-group-method gnus-newsgroup-name)) "nnimap") + (progn (gnus-select-newsgroup gnus-newsgroup-name nil + (nnimap-find-thread id refs)) + (when gnus-build-sparse-threads + (gnus-build-sparse-threads))) + (unless (eq gnus-fetch-old-headers 'invisible) + (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) + ;; Retrieve the headers and read them in. + (if (eq (if (numberp limit) + (gnus-retrieve-headers + (list (min + (+ (mail-header-number + (gnus-summary-article-header)) + limit) + gnus-newsgroup-end)) + gnus-newsgroup-name (* limit 2)) + ;; gnus-refer-thread-limit is t, i.e. fetch _all_ + ;; headers. + (gnus-retrieve-headers (list gnus-newsgroup-end) + gnus-newsgroup-name limit)) + 'nov) + (gnus-build-all-threads) + (error "Can't fetch thread from back ends that don't support NOV")) + (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))) + (gnus-summary-limit-include-thread id))) (defun gnus-summary-refer-article (message-id) "Fetch an article specified by MESSAGE-ID." --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=Changelog.diff Content-Description: ChangeLog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ab64bcc..c809021 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2010-10-12 Andrew Cohen + + * nnimap.el (nnimap-find-thread): New function. + + * nnir.el (gnus-summary-nnir-goto-thread): Use it. + + * gnus-sum.el (gnus-summary-refer-thread): Modify to work with + imap. + 2010-10-12 Katsumi Yamaoka * gnus-gravatar.el (gnus-gravatar-too-ugly): Don't test if --=-=-=--