Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Support hiding deleted IMAP messages
@ 2015-05-27  4:29 Nikolaus Rath
  2015-05-28 13:42 ` Eric Abrahamsen
  2015-07-02  2:36 ` [PATCH] Support hiding deleted IMAP messages (v2) Nikolaus Rath
  0 siblings, 2 replies; 6+ messages in thread
From: Nikolaus Rath @ 2015-05-27  4:29 UTC (permalink / raw)
  To: ding, submit

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap_hide_deleted.diff --]
[-- Type: text/x-diff, Size: 2915 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Support hiding deleted IMAP messages
  2015-05-27  4:29 [PATCH] Support hiding deleted IMAP messages Nikolaus Rath
@ 2015-05-28 13:42 ` Eric Abrahamsen
  2015-07-02  2:36 ` [PATCH] Support hiding deleted IMAP messages (v2) Nikolaus Rath
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Abrahamsen @ 2015-05-28 13:42 UTC (permalink / raw)
  To: ding

Nikolaus Rath <Nikolaus@rath.org> writes:

> 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

Hi Nikolaus,

I am in no way qualified to speak on behalf of Gnus and its developers,
but I did want to say thank you very much for these patches -- it will
be great to see Gnus gradually mature as an IMAP client. The development
of Gnus seems to go by fits and starts, as people have time to devote to
it, particular for relatively deep-plumbing areas like this, so it's
possible you won't get much response for a while -- don't be
discouraged! I'm on the road with a temporary computer now, but will be
happy to run your patches once I'm back home, and report any
problems/comments.

Thanks!
Eric




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Support hiding deleted IMAP messages (v2)
@ 2015-07-02  2:36 ` Nikolaus Rath
  2015-07-02 17:14   ` Andreas Schwab
  2017-01-26 19:15   ` bug#20672: " Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: Nikolaus Rath @ 2015-07-02  2:36 UTC (permalink / raw)
  To: ding, 20672

[-- Attachment #1: Type: text/plain, Size: 439 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap_hide_deleted.diff --]
[-- Type: text/x-diff, Size: 2965 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Support hiding deleted IMAP messages (v2)
  2015-07-02  2:36 ` [PATCH] Support hiding deleted IMAP messages (v2) Nikolaus Rath
@ 2015-07-02 17:14   ` Andreas Schwab
  2017-01-26 19:15   ` bug#20672: " Lars Ingebrigtsen
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2015-07-02 17:14 UTC (permalink / raw)
  To: ding; +Cc: 20672

Nikolaus Rath <Nikolaus@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bug#20672: [PATCH] Support hiding deleted IMAP messages (v2)
  2015-07-02  2:36 ` [PATCH] Support hiding deleted IMAP messages (v2) Nikolaus Rath
  2015-07-02 17:14   ` Andreas Schwab
@ 2017-01-26 19:15   ` Lars Ingebrigtsen
  2020-08-13  8:47     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2017-01-26 19:15 UTC (permalink / raw)
  To: ding; +Cc: 20672, Nikolaus Rath

Nikolaus Rath <Nikolaus@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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bug#20672: [PATCH] Support hiding deleted IMAP messages (v2)
  2017-01-26 19:15   ` bug#20672: " Lars Ingebrigtsen
@ 2020-08-13  8:47     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-13  8:47 UTC (permalink / raw)
  To: ding; +Cc: Nikolaus Rath, 20672

Lars Ingebrigtsen <larsi@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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-13  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27  4:29 [PATCH] Support hiding deleted IMAP messages Nikolaus Rath
2015-05-28 13:42 ` Eric Abrahamsen
2015-07-02  2:36 ` [PATCH] Support hiding deleted IMAP messages (v2) Nikolaus Rath
2015-07-02 17:14   ` Andreas Schwab
2017-01-26 19:15   ` bug#20672: " Lars Ingebrigtsen
2020-08-13  8:47     ` Lars Ingebrigtsen

Gnus development mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/ding

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 ding ding/ http://inbox.vuxu.org/ding \
		ding@inbox.vuxu.org
	public-inbox-index ding

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.emacs.gnus.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git