From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/85967 Path: news.gmane.org!not-for-mail From: Nikolaus Rath Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Support hiding deleted IMAP messages Date: Tue, 26 May 2015 21:29:51 -0700 Message-ID: <87d21m3ao0.fsf@vostro.rath.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1432701057 24470 80.91.229.3 (27 May 2015 04:30:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 May 2015 04:30:57 +0000 (UTC) To: ding@gnus.org, submit@debbugs.gnu.org Original-X-From: ding-owner+M34202@lists.math.uh.edu Wed May 27 06:30:47 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 1YxSzL-0004vq-Rl for ding-account@gmane.org; Wed, 27 May 2015 06:30:44 +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 1YxSyg-0007Ox-3j; Tue, 26 May 2015 23:30:02 -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 1YxSyd-0007OZ-TN for ding@lists.math.uh.edu; Tue, 26 May 2015 23:29:59 -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 1YxSyc-00008v-Jo for ding@lists.math.uh.edu; Tue, 26 May 2015 23:29:59 -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 1YxSya-0004lJ-Sh for ding@gnus.org; Wed, 27 May 2015 06:29:57 +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 1YxSyV-000252-Qg; Wed, 27 May 2015 04:29:51 +0000 Original-Received: by vostro.rath.org (Postfix, from userid 1000) id 69B76E74E20; Tue, 26 May 2015 21:29:51 -0700 (PDT) Mail-Copies-To: never Mail-Followup-To: ding@gnus.org, submit@debbugs.gnu.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:85967 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Package: gnus Tags: patch Hello, The attached patch introduces a new server variable, nnimap-hide-deleted. If non-nil, articles with the IMAP \Deleted flag will not be included in Summary buffers. This is intended to increase operability with other IMAP mailreaders and the new 'never value for nnimap-expunge (see patch in bug 20670). Thanks for considering. 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.bak 2015-05-26 19:28:32.453605543 -0700 +++ nnimap.el 2015-05-26 21:10:58.221688253 -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,17 @@ (and (re-search-forward "UID \\([0-9]+\\)" (line-end-position) t) (match-string 1))) - (setq lines nil) + (setq flags + (and (re-search-forward "FLAGS (\\([^)]+\\))" + (line-end-position) + t) + (split-string (match-string 1)))) (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 +267,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. --=-=-=--