From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/86075 Path: news.gmane.org!not-for-mail From: Nikolaus Rath Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: [PATCH] Use IMAP MOVE extension if available Date: Wed, 15 Jul 2015 17:29:47 -0700 Message-ID: <87io9l2bd0.fsf@vostro.rath.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1437006603 4789 80.91.229.3 (16 Jul 2015 00:30:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Jul 2015 00:30:03 +0000 (UTC) Cc: Eric Abrahamsen , ding , emacs-devel To: 20671@debbugs.gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 16 02:30:01 2015 Return-path: Envelope-to: ged-emacs-devel@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 1ZFX3n-0002mZ-9k for ged-emacs-devel@m.gmane.org; Thu, 16 Jul 2015 02:29:59 +0200 Original-Received: from localhost ([::1]:37915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFX3m-0002qM-IW for ged-emacs-devel@m.gmane.org; Wed, 15 Jul 2015 20:29:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFX3i-0002ly-P3 for emacs-devel@gnu.org; Wed, 15 Jul 2015 20:29:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFX3h-0005oG-CT for emacs-devel@gnu.org; Wed, 15 Jul 2015 20:29:54 -0400 Original-Received: from ebox.rath.org ([2600:3c01::f03c:91ff:fe69:db07]:47667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFX3h-0005n4-2t for emacs-devel@gnu.org; Wed, 15 Jul 2015 20:29:53 -0400 Original-Received: from vostro ([192.168.12.4] helo=vostro.rath.org) by ebox.rath.org with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.80) (envelope-from ) id 1ZFX3b-0004xm-Gs; Thu, 16 Jul 2015 00:29:47 +0000 Original-Received: by vostro.rath.org (Postfix, from userid 1000) id 20890EC65B2; Wed, 15 Jul 2015 17:29:47 -0700 (PDT) Mail-Copies-To: never Mail-Followup-To: 20671@debbugs.gnu.org, ding , emacs-devel , Eric Abrahamsen User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fe69:db07 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+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187894 gmane.emacs.gnus.general:86075 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, The attached revision fixes a small error when parsing the response to the UID MOVE command. Previously, it would fail to find the COPYUID response and fall back to using the message id to determine the UID of the copied message. Best, -Nikolaus --=20 GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2= =AB --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-nnimap.el-use-IMAP-MOVE-extension-if-available.patch >From f7cff6a6068079ecfb31d31986902b5b17cee0b5 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Thu, 9 Jul 2015 20:01:12 -0700 Subject: [PATCH] nnimap.el: use IMAP MOVE extension if available * lisp/nnimap.el (nnimap-request-move-article) (nnimap-process-expiry-targets, nnimap-split-incoming-mail): use MOVE extension if available. --- lisp/ChangeLog | 6 ++++++ lisp/nnimap.el | 59 ++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d4af26a..58d00ed 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,11 @@ 2015-07-11 Nikolaus Rath + * nnimap.el (nnimap-request-move-article) + (nnimap-process-expiry-targets, nnimap-split-incoming-mail): use MOVE + extension if available. + +2015-07-09 Nikolaus Rath + * nnimap.el (nnimap-hide-deleted): introduced as new server variable. (nnimap-header-parameters): also request flags. (nnimap-transform-headers): parse flags and conditionally skip over diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 2f4a818..f56fb83 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -960,17 +960,19 @@ If non-nil, articles flagged as deleted (using the IMAP ;; way. (let ((message-id (message-field-value "message-id"))) (if internal-move-group - (let ((result - (with-current-buffer (nnimap-buffer) - (nnimap-command "UID COPY %d %S" - article - (utf7-encode internal-move-group t))))) - (when (car result) - (nnimap-delete-article article) - (cons internal-move-group - (or (nnimap-find-uid-response "COPYUID" (cadr result)) - (nnimap-find-article-by-message-id - internal-move-group server message-id + (with-current-buffer (nnimap-buffer) + (let* ((can-move (nnimap-capability "MOVE")) + (command (if can-move + "UID MOVE %d %S" + "UID COPY %d %S")) + (result (nnimap-command command article + (utf7-encode internal-move-group t)))) + (when (and (car result) (not can-move)) + (nnimap-delete-article article)) + (cons internal-move-group + (or (nnimap-find-uid-response "COPYUID" (caddr result)) + (nnimap-find-article-by-message-id + internal-move-group server message-id nnimap-request-articles-find-limit))))) ;; Move the article to a different method. (let ((result (eval accept-form))) @@ -1009,11 +1011,12 @@ If non-nil, articles flagged as deleted (using the IMAP (gnus-sorted-complement articles deletable-articles)))))) (defun nnimap-process-expiry-targets (articles group server) - (let ((deleted-articles nil)) + (let ((deleted-articles nil) + (articles-to-delete nil)) (cond ;; shortcut further processing if we're going to delete the articles ((eq nnmail-expiry-target 'delete) - (setq deleted-articles articles) + (setq articles-to-delete articles) t) ;; or just move them to another folder on the same IMAP server ((and (not (functionp nnmail-expiry-target)) @@ -1023,11 +1026,14 @@ If non-nil, articles flagged as deleted (using the IMAP (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))) + (let ((can-move (nnimap-capability "MOVE"))) + (nnimap-command + (if can-move + "UID MOVE %s %S" + "UID COPY %s %S") + (nnimap-article-ranges (gnus-compress-sequence articles)) + (utf7-encode (gnus-group-real-name nnmail-expiry-target) t)) + (set (if can-move 'deleted-articles 'articles-to-delete) articles)))) t) (t (dolist (article articles) @@ -1048,11 +1054,13 @@ If non-nil, articles flagged as deleted (using the IMAP (setq target nil)) (nnheader-message 7 "Expiring article %s:%d" group article)) (when target - (push article deleted-articles)))))) - (setq deleted-articles (nreverse deleted-articles)))) + (push article articles-to-delete)))))) + (setq articles-to-delete (nreverse articles-to-delete)))) ;; Change back to the current group again. (nnimap-change-group group server) - (nnimap-delete-article (gnus-compress-sequence deleted-articles)) + (when articles-to-delete + (nnimap-delete-article (gnus-compress-sequence articles-to-delete)) + (setq deleted-articles articles-to-delete)) deleted-articles)) (defun nnimap-find-expired-articles (group) @@ -2103,6 +2111,7 @@ Return the server's response to the SELECT or EXAMINE command." nnmail-split-fancy)) (nnmail-inhibit-default-split-group t) (groups (nnimap-get-groups)) + (can-move (nnimap-capability "MOVE")) new-articles) (erase-buffer) (nnimap-command "SELECT %S" nnimap-inbox) @@ -2137,14 +2146,16 @@ Return the server's response to the SELECT or EXAMINE command." ;; Don't copy if the message is already in its ;; target group. (unless (string= group nnimap-inbox) - (push (list (nnimap-send-command - "UID COPY %s %S" + (push (list (nnimap-send-command + (if can-move + "UID MOVE %d %S" + "UID COPY %s %S") (nnimap-article-ranges ranges) (utf7-encode group t)) ranges) sequences))))) ;; Wait for the last COPY response... - (when sequences + (when (and (not can-move) sequences) (nnimap-wait-for-response (caar sequences)) ;; And then mark the successful copy actions as deleted, ;; and possibly expunge them. -- 2.1.4 --=-=-=--