GNU bug report logs - #20672
[PATCH] Support hiding deleted IMAP messages

Previous Next

Packages: gnus, emacs;

Reported by: Nikolaus Rath <Nikolaus <at> rath.org>

Date: Wed, 27 May 2015 04:30:08 UTC

Severity: wishlist

Tags: patch

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20672 in the body.
You can then email your comments to 20672 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Wed, 27 May 2015 04:30:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nikolaus Rath <Nikolaus <at> rath.org>:
New bug report received and forwarded. Copy sent to bugs <at> gnus.org. (Wed, 27 May 2015 04:30:10 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nikolaus Rath <Nikolaus <at> rath.org>
To: ding <at> gnus.org, submit <at> debbugs.gnu.org
Subject: [PATCH] Support hiding deleted IMAP messages
Date: Tue, 26 May 2015 21:29:51 -0700
[Message part 1 (text/plain, inline)]
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

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
[nnimap_hide_deleted.diff (text/x-diff, inline)]
--- 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.

Information forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Thu, 02 Jul 2015 02:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Nikolaus Rath <Nikolaus <at> rath.org>
To: ding <at> gnus.org, 20672 <at> debbugs.gnu.org
Subject: [PATCH] Support hiding deleted IMAP messages (v2)
Date: Wed, 01 Jul 2015 19:36:57 -0700
[Message part 1 (text/plain, inline)]
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

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
[nnimap_hide_deleted.diff (text/x-diff, inline)]
--- 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.

Information forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Thu, 02 Jul 2015 17:15:03 GMT) Full text and rfc822 format available.

Message #11 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: ding <at> gnus.org
Cc: 20672 <at> debbugs.gnu.org
Subject: Re: [PATCH] Support hiding deleted IMAP messages (v2)
Date: Thu, 02 Jul 2015 19:14:37 +0200
Nikolaus Rath <Nikolaus <at> rath.org> writes:

> +(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.")
> +

The first line of a doc string should be a complete sentence.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Fri, 03 Jul 2015 02:18:01 GMT) Full text and rfc822 format available.

Message #14 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Nikolaus Rath <Nikolaus <at> rath.org>
To: ding <at> gnus.org, 20672 <at> debbugs.gnu.org
Subject: [PATCH] Support hiding deleted IMAP messages (v3)
Date: Thu, 02 Jul 2015 19:17:28 -0700
[Message part 1 (text/plain, inline)]
Hello,

This 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).

Changes in v2:

  * Take into account that server may send the UID, FLAGS and RFC822.SIZE
    response data items in arbitrary order

Changes in v3:

  * Made first line of docstring a complete sentence.

Thanks for considering,
-Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
[nnimap_hide_deleted_v3.diff (text/x-diff, inline)]
diff --git a/nnimap.el b/nnimap.el
--- a/nnimap.el
+++ b/nnimap.el
@@ -135,6 +135,11 @@
 likely value would be \"text/\" to automatically fetch all
 textual parts.")
 
+(defvoo nnimap-hide-deleted nil
+  "Whether to hide deletes messages in summary buffer.
+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)
@@ -181,7 +186,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]"
@@ -240,12 +245,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
@@ -259,20 +271,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.

Information forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Fri, 03 Jul 2015 14:19:03 GMT) Full text and rfc822 format available.

Message #17 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Greg Troxel <gdt <at> lexort.com>
To: ding <at> gnus.org
Cc: 20672 <at> debbugs.gnu.org
Subject: Re: [PATCH] Support hiding deleted IMAP messages (v3)
Date: Fri, 03 Jul 2015 09:44:28 -0400
[Message part 1 (text/plain, inline)]
Nikolaus Rath <Nikolaus <at> rath.org> writes:

> This 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).

I haven't reviewed the patch, but the functionality is needed.  I find
that on deleting messages with GUI IMAP clients, they are still seen in
gnus.

I find the deletion notion in IMAP confusing, between move-to-trash and
just-marked-deleted-but-keep, and don't really know how the articles end
up in the trash folder using the just-mark scheme, but it hasn't
bothered me enough to dig in.   I do find myself deleting things twice
once in $GUI_IMAP, and once in gus.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bugs <at> gnus.org:
bug#20672; Package gnus. (Thu, 26 Jan 2017 19:25:02 GMT) Full text and rfc822 format available.

Message #20 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: ding <at> gnus.org
Cc: Nikolaus Rath <Nikolaus <at> rath.org>, 20672 <at> debbugs.gnu.org
Subject: Re: bug#20672: [PATCH] Support hiding deleted IMAP messages (v2)
Date: Thu, 26 Jan 2017 20:15:11 +0100
Nikolaus Rath <Nikolaus <at> rath.org> writes:

> 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.

[...]

> +        (if (and nnimap-hide-deleted
> +                 (member "\\Deleted" flags))
> +            (delete-region (line-beginning-position)
> +                           (or (re-search-forward "^\r$\\|^)\r?$" nil t)
> +                               (point-max)))

Hm...  won't this make Gnus think that the articles doesn't exist?  So
they'll end up in the "unexist tracking" list?  I don't think that's
correct...

I think it would be better to just convey the information up to the Gnus
layer, and then Gnus could have a switch to not display these deleted
messages.

Or perhaps just pretend like all \Deleted messages are \Read?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug reassigned from package 'gnus' to 'emacs,gnus'. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 26 Jan 2017 19:25:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#20672; Package emacs,gnus. (Thu, 13 Aug 2020 08:48:01 GMT) Full text and rfc822 format available.

Message #25 received at 20672 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: ding <at> gnus.org
Cc: Nikolaus Rath <Nikolaus <at> rath.org>, 20672 <at> debbugs.gnu.org
Subject: Re: bug#20672: [PATCH] Support hiding deleted IMAP messages (v2)
Date: Thu, 13 Aug 2020 10:47:33 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I think it would be better to just convey the information up to the Gnus
> layer, and then Gnus could have a switch to not display these deleted
> messages.
>
> Or perhaps just pretend like all \Deleted messages are \Read?

Apparently, that's what we've been doing since 2013:

	    (let* ((unread
		    (gnus-compress-sequence
		     (gnus-set-difference
		      (gnus-set-difference
		       existing
		       (gnus-sorted-union
			(cdr (assoc '%Seen flags))
			(cdr (assoc '%Deleted flags))))
		      (cdr (assoc '%Flagged flags)))))
		   (read (gnus-range-difference
			  (cons start-article high) unread)))

So I think re-handling this (as the patch suggested) should be
unnecessary, so I'm closing this bug report.

If the problem still exists, please respond to this email and we'll
reopen the bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 20672 <at> debbugs.gnu.org and Nikolaus Rath <Nikolaus <at> rath.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 13 Aug 2020 08:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 10 Sep 2020 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 229 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.