From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#18351: [Alan Schmitt] Small patch for gnus nnimap.el Date: Thu, 28 Aug 2014 21:19:13 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===-=-=" X-Trace: ger.gmane.org 1409275238 11038 80.91.229.3 (29 Aug 2014 01:20:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Aug 2014 01:20:38 +0000 (UTC) Cc: Alan Schmitt To: 18351@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 29 03:20:31 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XNArf-0004cY-46 for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Aug 2014 03:20:31 +0200 Original-Received: from localhost ([::1]:39673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNAre-0000Ft-IY for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Aug 2014 21:20:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNArR-0000Fl-OS for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:20:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNArF-00044v-QD for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:20:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNArF-00043s-NB for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:20:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XNArC-0006l3-FX; Thu, 28 Aug 2014 21:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: alan.schmitt@polytechnique.org, bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Fri, 29 Aug 2014 01:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18351 X-GNU-PR-Package: emacs,gnus X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Alan Schmitt Original-Received: via spool by submit@debbugs.gnu.org id=B.140927518525946 (code B ref -1); Fri, 29 Aug 2014 01:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Aug 2014 01:19:45 +0000 Original-Received: from localhost ([127.0.0.1]:52950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XNAqt-0006kP-MW for submit@debbugs.gnu.org; Thu, 28 Aug 2014 21:19:44 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37428) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XNAqr-0006kC-49 for submit@debbugs.gnu.org; Thu, 28 Aug 2014 21:19:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNAqe-0003f3-Rg for submit@debbugs.gnu.org; Thu, 28 Aug 2014 21:19:35 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNAqe-0003ez-P3 for submit@debbugs.gnu.org; Thu, 28 Aug 2014 21:19:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNAqY-00008x-L0 for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:19:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNAqS-0003d5-G0 for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:19:22 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:46048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNAqS-0003d1-Av for bug-gnu-emacs@gnu.org; Thu, 28 Aug 2014 21:19:16 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s7T1JEmj031499; Thu, 28 Aug 2014 21:19:14 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id D603CAE88E; Thu, 28 Aug 2014 21:19:13 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.5 X-NAI-Spam-Rules: 2 Rules triggered WDWDW_ADDR=0.5, RV5047=0 X-NAI-Spam-Version: 2.3.0.9378 : core <5047> : inlines <1220> : streams <1276310> : uri <1807832> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92789 Archived-At: --===-=-= Content-Type: text/plain Package:emacs,gnus Thanks Alan for your detailed bug-report with patch. Turning this to the bug-tracker, so we have a tracking number for it. Stefan --===-=-= Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 8bit Return-Path: X-Original-To: monnier@iro.umontreal.ca Delivered-To: monnier@iro.umontreal.ca Received: from pinpin.iro.umontreal.ca (pinpin.iro.umontreal.ca [132.204.24.52]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id B6F9A84E83 for ; Wed, 27 Aug 2014 02:55:45 -0400 (EDT) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by pinpin.iro.umontreal.ca (Postfix) with ESMTP id EC7253B9054 for ; Wed, 27 Aug 2014 02:55:25 -0400 (EDT) Received: from localhost ([::1]:57824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMX8f-0002C5-QS for monnier@iro.umontreal.ca; Wed, 27 Aug 2014 02:55:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMX8S-0002Aq-Il for emacs-devel@gnu.org; Wed, 27 Aug 2014 02:55:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMX8M-0007I5-DH for emacs-devel@gnu.org; Wed, 27 Aug 2014 02:55:12 -0400 Received: from plane.gmane.org ([80.91.229.3]:47698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMX8M-0007Am-2k for emacs-devel@gnu.org; Wed, 27 Aug 2014 02:55:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XMX8K-0002KV-BG for emacs-devel@gnu.org; Wed, 27 Aug 2014 08:55:04 +0200 Received: from top-wifi.irisa.fr ([131.254.66.192]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Aug 2014 08:55:04 +0200 Received: from alan.schmitt by top-wifi.irisa.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Aug 2014 08:55:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-devel@gnu.org From: Alan Schmitt Subject: Small patch for gnus nnimap.el Date: Wed, 27 Aug 2014 08:45:15 +0200 Lines: 172 Message-ID: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: top-wifi.irisa.fr User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (darwin) Cancel-Lock: sha1:qgRFoTFVr+XHknU+V++tSw2NKgo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+monnier=iro.umontreal.ca@gnu.org Sender: emacs-devel-bounces+monnier=iro.umontreal.ca@gnu.org X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-1.94, requis 5, BAYES_00 -2.60, MC_TSTLAST 0.00, RECEIVED_FROM_NOUNK 0.66, SPF_HELO_PASS -0.00) X-DIRO-MailScanner-From: emacs-devel-bounces+monnier=iro.umontreal.ca@gnu.org X-Spam-Status: No --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hello, I posted this on gnus.general a couple weeks ago, but nobody replied. I'm thus wondering if emacs.devel might be a better place to send gnus patches. If not, could you please direct me to the correct place? 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) iQEcBAEBCgAGBQJT/X6DAAoJEAQNCjtO0uXHKywIAIqp/RP/Uh1KBESMSMKd6VFV 6w9cnDPdLmEv+3RhyZ01iWdLnn399s16jRB078Dk2mexCgdmeAunhm0URfwJeF2M lCfz2vbyuSYPBMjzt3H65zGXU4Z8vbzaOW3rX0SWIeQ4A/bwBM+RgIfmvT+EdflJ k6coW5LhLQdE9e/byVqUSw5/DodcQBurvupTWWRahP2Iw0QOzgAfbfmuuqPNARtI S6pUjdHAYBMVpBIYw05nH1heGWEPBfFUUXDa7XLpiBPSYyhWo5KN2VHiaZeknKIG ly+1XSJWol1mjj7Hmol3FOuKk2bUvwe8SBQb82PGXuhm+iNcT0kLdn9iDR+jDmA= =3Bhq -----END PGP SIGNATURE----- --==-=-=-- --===-=-=--