From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/86019 Path: news.gmane.org!not-for-mail From: Nikolaus Rath Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Support hiding deleted IMAP messages (v2) Date: Wed, 01 Jul 2015 19:36:57 -0700 Message-ID: <873817cmk6.fsf@vostro.rath.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1435804654 25376 80.91.229.3 (2 Jul 2015 02:37:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Jul 2015 02:37:34 +0000 (UTC) To: ding@gnus.org, 20672@debbugs.gnu.org Original-X-From: ding-owner+M34254@lists.math.uh.edu Thu Jul 02 04:37:23 2015 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from lists1.math.uh.edu ([129.7.128.208]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZAUNN-0006je-B7 for ding-account@gmane.org; Thu, 02 Jul 2015 04:37:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.84) (envelope-from ) id 1ZAUN6-0005mf-U7; Wed, 01 Jul 2015 21:37:04 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1ZAUN5-0005mQ-Bb for ding@lists.math.uh.edu; Wed, 01 Jul 2015 21:37:03 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from ) id 1ZAUN4-0000He-26 for ding@lists.math.uh.edu; Wed, 01 Jul 2015 21:37:03 -0500 Original-Received: from ebox.rath.org ([23.92.25.96]) by quimby.gnus.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ZAUN2-0000QL-CB for ding@gnus.org; Thu, 02 Jul 2015 04:37:00 +0200 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 1ZAUN0-0001fs-3h; Thu, 02 Jul 2015 02:36:58 +0000 Original-Received: by vostro.rath.org (Postfix, from userid 1000) id BA9F3EC421D; Wed, 1 Jul 2015 19:36:57 -0700 (PDT) Mail-Copies-To: never Mail-Followup-To: ding@gnus.org, 20672@debbugs.gnu.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Spam-Score: -1.7 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:86019 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, The previous patch did not take into account that an IMAP server is free to send the UID, FLAGS and RFC822.SIZE response data items in arbitrary order. This has been fixed in this version of the patch. 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: inline; filename=nnimap_hide_deleted.diff --- nnimap.el.bak3 2015-05-26 19:27:53.797971148 -0700 +++ nnimap.el.bak4 2015-07-01 19:20:21.220598632 -0700 @@ -134,6 +134,10 @@ likely value would be \"text/\" to automatically fetch all textual parts.") +(defvoo nnimap-hide-deleted nil + "If non-nil, articles flagged as deleted (using the IMAP +\\Delete flag) will not be shown in the Summary buffer.") + (defgroup nnimap nil "IMAP for Gnus." :group 'gnus) @@ -180,7 +184,7 @@ (nnimap-find-process-buffer nntp-server-buffer)) (defun nnimap-header-parameters () - (format "(UID RFC822.SIZE BODYSTRUCTURE %s)" + (format "(UID FLAGS RFC822.SIZE BODYSTRUCTURE %s)" (format (if (nnimap-ver4-p) "BODY.PEEK[HEADER.FIELDS %s]" @@ -239,12 +243,19 @@ (and (re-search-forward "UID \\([0-9]+\\)" (line-end-position) t) (match-string 1))) - (setq lines nil) + (beginning-of-line) + (setq flags + (and (re-search-forward "FLAGS (\\([^)]+\\))" + (line-end-position) + t) + (split-string (match-string 1)))) + (beginning-of-line) (setq size (and (re-search-forward "RFC822.SIZE \\([0-9]+\\)" (line-end-position) t) (match-string 1))) + (setq lines nil) (beginning-of-line) (when (search-forward "BODYSTRUCTURE" (line-end-position) t) (let ((structure (ignore-errors @@ -258,20 +269,25 @@ (equal (upcase (nth 1 structure)) "RFC822")) (nth 9 structure) (nth 7 structure))))) - (delete-region (line-beginning-position) (line-end-position)) - (insert (format "211 %s Article retrieved." article)) - (forward-line 1) - (when size - (insert (format "Chars: %s\n" size))) - (when lines - (insert (format "Lines: %s\n" lines))) - ;; Most servers have a blank line after the headers, but - ;; Davmail doesn't. - (unless (re-search-forward "^\r$\\|^)\r?$" nil t) - (goto-char (point-max))) - (delete-region (line-beginning-position) (line-end-position)) - (insert ".") - (forward-line 1))))) + (if (and nnimap-hide-deleted + (member "\\Deleted" flags)) + (delete-region (line-beginning-position) + (or (re-search-forward "^\r$\\|^)\r?$" nil t) + (point-max))) + (delete-region (line-beginning-position) (line-end-position)) + (insert (format "211 %s Article retrieved." article)) + (forward-line 1) + (when size + (insert (format "Chars: %s\n" size))) + (when lines + (insert (format "Lines: %s\n" lines))) + ;; Most servers have a blank line after the headers, but + ;; Davmail doesn't. + (unless (re-search-forward "^\r$\\|^)\r?$" nil t) + (goto-char (point-max))) + (delete-region (line-beginning-position) (line-end-position)) + (insert ".") + (forward-line 1)))))) (defun nnimap-unfold-quoted-lines () ;; Unfold quoted {number} strings. --=-=-=--