From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84766 Path: news.gmane.org!not-for-mail From: Alan Schmitt Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] bug in 'nnimap-process-expiry-targets' (nnimap.el)? Date: Mon, 11 Aug 2014 16:35:18 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1407767777 11165 80.91.229.3 (11 Aug 2014 14:36:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Aug 2014 14:36:17 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M33009@lists.math.uh.edu Mon Aug 11 16:36:10 2014 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 1XGqhl-0006Ws-IY for ding-account@gmane.org; Mon, 11 Aug 2014 16:36:10 +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 1XGqhU-00065d-Jz; Mon, 11 Aug 2014 09:35:52 -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 1XGqhT-00065U-5N for ding@lists.math.uh.edu; Mon, 11 Aug 2014 09:35:51 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1XGqhS-000815-44 for ding@lists.math.uh.edu; Mon, 11 Aug 2014 09:35:51 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1XGqhQ-0003SI-Mt for ding@gnus.org; Mon, 11 Aug 2014 16:35:48 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XGqhJ-0006Ex-MF for ding@gnus.org; Mon, 11 Aug 2014 16:35:41 +0200 Original-Received: from cbg35-2-78-242-14-140.fbx.proxad.net ([78.242.14.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 Aug 2014 16:35:41 +0200 Original-Received: from alan.schmitt by cbg35-2-78-242-14-140.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 Aug 2014 16:35:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 165 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cbg35-2-78-242-14-140.fbx.proxad.net User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (darwin) Cancel-Lock: sha1:tNDBobUfZ8vvBip8FdyBuE7ykSU= X-Spam-Score: -3.6 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:84766 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hello, As I'm trying to make the registry working with expiration, I think I found a bug in nnimap.el. Here is the code in question. #+begin_src emacs-lisp (defun nnimap-process-expiry-targets (articles group server) (let ((deleted-articles nil)) (cond ;; shortcut further processing if we're going to delete the articles ((eq nnmail-expiry-target 'delete) (setq deleted-articles articles) t) ;; or just move them to another folder on the same IMAP server ((and (not (functionp nnmail-expiry-target)) (gnus-server-equal (gnus-group-method nnmail-expiry-target) (gnus-server-to-method (format "nnimap:%s" server)))) (and (nnimap-change-group group server) (with-current-buffer (nnimap-buffer) (nnheader-message 7 "Expiring articles from %s: %s" group articles) (nnimap-command "UID COPY %s %S" (nnimap-article-ranges (gnus-compress-sequence articles)) (utf7-encode (gnus-group-real-name nnmail-expiry-target) t)) (setq deleted-articles articles))) t) (t (dolist (article articles) (let ((target nnmail-expiry-target)) (with-temp-buffer (mm-disable-multibyte) (when (nnimap-request-article article group server (current-buffer)) (when (functionp target) (setq target (funcall target group))) (if (and target (not (eq target 'delete))) (if (or (gnus-request-group target t) (gnus-request-create-group target)) (progn (nnmail-expiry-target-group target group) (nnheader-message 7 "Expiring article %s:%d to %s" group article target)) (setq target nil)) (nnheader-message 7 "Expiring article %s:%d" group article)) (when target (push article deleted-articles)))))))) ;; Change back to the current group again. (nnimap-change-group group server) (setq deleted-articles (nreverse deleted-articles)) (nnimap-delete-article (gnus-compress-sequence deleted-articles)) deleted-articles)) #+end_src The result of this function should be a list or messages that have been deleted, ordered by '<' (since 'gnus-sorted-complement' is then called on that list). If articles are deleted or sent to a static group on the same server, then 'deleted-articles' is just set to the list of all articles to expire. Otherwise each article is considered in turn, and articles that were successfully moved are put in the deleted-articles list. The problem with this function is that the list of deleted articles is reversed in every case, but it should only be reversed in the last case (when it was created considering each article in turn and pushing it onto the list, thus creating it in reverse). Attached is a patch fixing this. As an example why the current behavior is wrong, here is part of a debugging session: > Result: (4402 4406 4409 4414 4415) >=20 > Result: "work" >=20 > Expiring articles from work: (4402 4406 4415) > Result: (4402 4406 4409 4414 4406 4402) The first list is the list of all articles to consider. Then the articles "(4402 4406 4415)" are expired, and the result should be the remaining articles. Here the list of expired articles was reversed, and when taking the complement only 4415 was removed (since it's assumed it's ordered by '<') and the other remaining articles were put at the end. If you agree with this analysis, could you please apply this patch? I have a question about the code above. Why do the first two cases of the cond return a 't' at the end? Thanks, Alan --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Only-reverse-list-of-expired-messages-when-in-wrong-.patch Content-Transfer-Encoding: quoted-printable From=20073f9742158e42460fa24c414d6589e552873af5 Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Mon, 11 Aug 2014 16:32:08 +0200 Subject: [PATCH] Only reverse list of expired messages when in wrong order * lisp/nnimap.el (nnimap-process-expiry-targets): the list of expired messages should only be reversed when it was built in reverse order. =2D-- lisp/nnimap.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 1730bd4..ad48d47 100644 =2D-- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -986,10 +986,10 @@ textual parts.") (setq target nil)) (nnheader-message 7 "Expiring article %s:%d" group article)) (when target =2D (push article deleted-articles)))))))) + (push article deleted-articles)))))) + (setq deleted-articles (nreverse deleted-articles)))) ;; Change back to the current group again. (nnimap-change-group group server) =2D (setq deleted-articles (nreverse deleted-articles)) (nnimap-delete-article (gnus-compress-sequence deleted-articles)) deleted-articles)) =20 =2D-=20 2.0.3 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJT6NSuAAoJEAQNCjtO0uXHYUoIAK7nUahUgWneu0TMuHKBOOWo U+kaTV9pRzeOaI1t5b+J2Omq3GbyQyJ/qSejXE5GGgFFN+nhtlG3hoil+Z6mW5Zz ZtFvdXnmEu6cR4bw9fMOnhcq9j0ZCOFPGGmshco4UnvER06oE7XEPJmvKWEzUkMB ly66muffKRM/hblhv9zKoxmkkKo+aJdM1N6CSRb+9vKwI4DeQYKD6169ZLfuukkI LtK3t2LvSoN1igo4cSPm3ViiEJUQKXLznX9UEaPJQMkqL9gBK965lSNNAHET8BK0 WLNtZ4OunzUWzKqQHcHWaFDZeoeRi7VuVIstZXV8d78NMkx0KvjiTUaGSPUYtYk= =Fm5q -----END PGP SIGNATURE----- --==-=-=--