From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/81953 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.gnus.general Subject: Re: searching by Message-ID after copy/move; speeding things up Date: Fri, 15 Jun 2012 16:17:19 +0200 Message-ID: <87k3z8ek28.fsf@zelenka.enovance.com> References: <87395ypkri.fsf@maru.md5i.com> <877gvamhzv.fsf@zelenka.enovance.com> <87395x7jgn.fsf@zelenka.enovance.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1339769919 27939 80.91.229.3 (15 Jun 2012 14:18:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2012 14:18:39 +0000 (UTC) Cc: ding@gnus.org, Michael Welsh Duggan To: Michael Welsh Duggan Original-X-From: ding-owner+M30223@lists.math.uh.edu Fri Jun 15 16:18:36 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SfXM6-0000OC-A8 for ding-account@gmane.org; Fri, 15 Jun 2012 16:18:30 +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 1SfXL9-0003xI-GZ; Fri, 15 Jun 2012 09:17:31 -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 1SfXL8-0003x5-0Y for ding@lists.math.uh.edu; Fri, 15 Jun 2012 09:17:30 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1SfXL5-00018r-Sf for ding@lists.math.uh.edu; Fri, 15 Jun 2012 09:17:29 -0500 Original-Received: from prometheus.naquadah.org ([212.85.154.174] helo=mx1.naquadah.org) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1SfXL3-00021U-QZ for ding@gnus.org; Fri, 15 Jun 2012 16:17:25 +0200 Original-Received: from zelenka.enovance.com (unknown [83.167.43.235]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.naquadah.org (Postfix) with ESMTPSA id 613B35C1AE; Fri, 15 Jun 2012 16:17:20 +0200 (CEST) Mail-Followup-To: Michael Welsh Duggan , ding@gnus.org, Michael Welsh Duggan In-Reply-To: (Michael Welsh Duggan's message of "Thu, 14 Jun 2012 16:11:55 -0400") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:81953 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain On Thu, Jun 14 2012, Michael Welsh Duggan wrote: > Honestly, I'd just do a limited search. You're already doing an > EXAMINE, so you just need to parse the results to get the EXISTS count. > Then a "UID SEARCH N:* HEADER Message-ID ..." where N is the exist > count minus a small constant. > > If the limited search fails, just re-call the function with recent set > to nil. Another try. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-recent-argument-to-nnimap-find-article-by-messag.patch Content-Transfer-Encoding: quoted-printable From=20f14188ce0cdfba2bfe27bcf8e88b3945841a3a4b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 14 Jun 2012 10:09:04 +0200 Subject: [PATCH] Add recent argument to nnimap-find-article-by-message-id Signed-off-by: Julien Danjou =2D-- lisp/nnimap.el | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 1db8640..e50fc0e 100644 =2D-- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -123,6 +123,10 @@ will fetch all parts that have types that match that s= tring. A likely value would be \"text/\" to automatically fetch all textual parts.") =20 +(defcustom nnimap-request-move-articles-find-limit nil + "Limit the number of articles to look for after moving an article." + :type 'integer) + (defvar nnimap-process nil) =20 (defvar nnimap-status-string "") @@ -867,7 +871,8 @@ textual parts.") (cons internal-move-group (or (nnimap-find-uid-response "COPYUID" (cadr result)) (nnimap-find-article-by-message-id =2D internal-move-group server message-id))))) + internal-move-group server message-id + nnimap-request-move-articles-find-limit))))) ;; Move the article to a different method. (let ((result (eval accept-form))) (when result @@ -969,21 +974,28 @@ textual parts.") (cdr (assoc "SEARCH" (cdr result)))))))))) =20 =20 =2D(defun nnimap-find-article-by-message-id (group server message-id) =2D "Search for message with MESSAGE-ID in GROUP from SERVER." +(defun nnimap-find-article-by-message-id (group server message-id &optiona= l limit) + "Search for message with MESSAGE-ID in GROUP from SERVER. +If LIMIT, first try to limit the search to the N last articles." (with-current-buffer (nnimap-buffer) (erase-buffer) =2D (nnimap-change-group group server nil t) =2D (let ((sequence =2D (nnimap-send-command "UID SEARCH HEADER Message-Id %S" message-id)) =2D article result) =2D (setq result (nnimap-wait-for-response sequence)) =2D (when (and result =2D (car (setq result (nnimap-parse-response)))) =2D ;; Select the last instance of the message in the group. =2D (and (setq article =2D (car (last (cdr (assoc "SEARCH" (cdr result)))))) =2D (string-to-number article)))))) + (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 limit + (format " %s:*" (- number-of-article = limit)) + "") + message-id))) + (when (nnimap-wait-for-response sequence) + (let ((article (car (last (cdr (assoc "SEARCH" (nnimap-parse-respo= nse))))))) + (if article + (string-to-number article) + (when limit + (nnimap-find-article-by-message-id group server message-id))= )))))) =20 (defun nnimap-delete-article (articles) (with-current-buffer (nnimap-buffer) =2D-=20 1.7.10 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable While I was at it I modified a bunch of code in nnimap that I pushed into master. I hope I didn't break anything, but I think it's a bit cleaner that way. If it break something we can beat me and revert anyway. =2D-=20 Julien --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJP20PvAAoJEGEbqVCLeKXCo6wP/AnWi/JvicoGG0le7Z5+aRbu XAEJBMVA7DPQGjLGpj2XGPRe9Cjhxh3x/Id+o62IJDBIqaYvvROu9GMBQbQWEPu4 5DyaM7EcQTLKH7qwlxEhJlNaGHR99jpVGacgbeiGjGqARiy6P9rAsUacey6M9BDc KxD9+yxNiXeRg04v6W9Fkoz/TQPUd8zyXKMwBtwZwDzppEQ9ph0Hv+zkBBFMaqty +GSlFk+mjeiUINCIwk7u+/KkMu2DOBshOpvQUJTTqeg1TTlFV3IuvsYR42DacMu5 SOt/hkoeKWcIfB6f06uaeAsfe6bwVVfdZf2Zqrzq8v0L2wkKoUYFCgj6P8Vca1+d TLiza+57okLkKudap5Ym5ALoo6bUZqirH+m2GST4DniWA/8XArwr3v+ATAB4iLEp moX0cOrWP6PIW8PnuTv9p2Uc43K6PF3aIrnZlQBE7cpQZ7wkZpgxezl6GhyYD9iX 07Cj+tCuJxGZiiBpsba8ZWHj+boFujeMAiRdrRafAzqf1CsvNQpkY9M3W0zSZbyF /SaENi7/unLVFLN0XAeO7EFjCGSuAa3JJVoUGtOAUV070g4sFdRe3591eUhNvUK3 FUzMC9zY8SXs1wMQYb2pgPLmxL3vYVH28kWAQv+ivlFR4UwpycPKrvDqI4pJorIc 2wbjmknuyOUJkps64S60 =pvGZ -----END PGP SIGNATURE----- --==-=-=--