Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Support hiding deleted IMAP messages (v3)
@ 2015-07-03  2:17 Nikolaus Rath
  2015-07-03 13:44 ` Greg Troxel
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolaus Rath @ 2015-07-03  2:17 UTC (permalink / raw)
  To: ding, 20672

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

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

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

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.

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

* Re: [PATCH] Support hiding deleted IMAP messages (v3)
  2015-07-03  2:17 [PATCH] Support hiding deleted IMAP messages (v3) Nikolaus Rath
@ 2015-07-03 13:44 ` Greg Troxel
  2015-07-03 19:02   ` Nikolaus Rath
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Troxel @ 2015-07-03 13:44 UTC (permalink / raw)
  To: ding; +Cc: 20672

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


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

[-- Attachment #2: Type: application/pgp-signature, Size: 180 bytes --]

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

* Re: [PATCH] Support hiding deleted IMAP messages (v3)
  2015-07-03 13:44 ` Greg Troxel
@ 2015-07-03 19:02   ` Nikolaus Rath
  2015-07-03 23:09     ` Greg Troxel
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolaus Rath @ 2015-07-03 19:02 UTC (permalink / raw)
  To: ding

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

On Jul 03 2015, Greg Troxel <gdt@lexort.com> wrote:
> Nikolaus Rath <Nikolaus@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.

It's really pretty simple. There is no concept of a trash folder in
IMAP. Deleting a message means marking it with the \Deleted flag. The UA
is expected to take that into account when showing the mailbox contents
(e.g. by hiding such messsages or showing them crossed out). A message
can be physically deleted by "expunging" it (that would correspond to
emptying the trash).

Any trash folder in an IMAP mailbox is a totally ordinary folder, and if
there are messages in it it means that they have been moved there (i.e.,
not deleted). To empty the trash, you still have to mark the message as
\Deleted, *and* then expunge it.



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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 997 bytes --]

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

* Re: [PATCH] Support hiding deleted IMAP messages (v3)
  2015-07-03 19:02   ` Nikolaus Rath
@ 2015-07-03 23:09     ` Greg Troxel
  2015-07-04  1:53       ` Nikolaus Rath
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Troxel @ 2015-07-03 23:09 UTC (permalink / raw)
  To: ding

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


Nikolaus Rath <Nikolaus@rath.org> writes:

> It's really pretty simple. There is no concept of a trash folder in
> IMAP. Deleting a message means marking it with the \Deleted flag. The UA
> is expected to take that into account when showing the mailbox contents
> (e.g. by hiding such messsages or showing them crossed out). A message
> can be physically deleted by "expunging" it (that would correspond to
> emptying the trash).

OK, but it seems many MUAs have a notion of moving messages to a trash
folder instead of just IMAP deletion.

Do MUAs that behave the way you say have  "trash" mailbox in the UI
that is  really the set of messages in other mailboxes (or inbox)
that have the \Deleted flag set?

> Any trash folder in an IMAP mailbox is a totally ordinary folder, and if
> there are messages in it it means that they have been moved there (i.e.,
> not deleted). To empty the trash, you still have to mark the message as
> \Deleted, *and* then expunge it.

But I empty trash by total-expire in gnus, on the trash mailbox :-)

[-- Attachment #2: Type: application/pgp-signature, Size: 180 bytes --]

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

* Re: [PATCH] Support hiding deleted IMAP messages (v3)
  2015-07-03 23:09     ` Greg Troxel
@ 2015-07-04  1:53       ` Nikolaus Rath
  0 siblings, 0 replies; 5+ messages in thread
From: Nikolaus Rath @ 2015-07-04  1:53 UTC (permalink / raw)
  To: ding

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

On Jul 03 2015, Greg Troxel <gdt@lexort.com> wrote:
> Nikolaus Rath <Nikolaus@rath.org> writes:
>
>> It's really pretty simple. There is no concept of a trash folder in
>> IMAP. Deleting a message means marking it with the \Deleted flag. The UA
>> is expected to take that into account when showing the mailbox contents
>> (e.g. by hiding such messsages or showing them crossed out). A message
>> can be physically deleted by "expunging" it (that would correspond to
>> emptying the trash).
>
> OK, but it seems many MUAs have a notion of moving messages to a trash
> folder instead of just IMAP deletion.
>
> Do MUAs that behave the way you say have  "trash" mailbox in the UI
> that is  really the set of messages in other mailboxes (or inbox)
> that have the \Deleted flag set?

Theoretically they could, in practice I don't know any MUA that does
this. They all have a trash mailbox in the imap account, and move
messages there instead of deleting them.

>> Any trash folder in an IMAP mailbox is a totally ordinary folder, and if
>> there are messages in it it means that they have been moved there (i.e.,
>> not deleted). To empty the trash, you still have to mark the message as
>> \Deleted, *and* then expunge it.
>
> But I empty trash by total-expire in gnus, on the trash mailbox :-)

That's the same thing. By default, deleting in Gnus means setting the
\Delete flag *and* immediately running expunge. But I've submitted
another patch that changes this, so that you can skip the expunge step. 


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 997 bytes --]

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

end of thread, other threads:[~2015-07-04  1:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03  2:17 [PATCH] Support hiding deleted IMAP messages (v3) Nikolaus Rath
2015-07-03 13:44 ` Greg Troxel
2015-07-03 19:02   ` Nikolaus Rath
2015-07-03 23:09     ` Greg Troxel
2015-07-04  1:53       ` Nikolaus Rath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).