Gnus development mailing list
 help / color / mirror / Atom feed
From: Leonidas Tsampros <ltsampros@upnet.gr>
To: ding@gnus.org
Subject: Re: [PATCH] gmail and X-GM-EXT1 extensions
Date: Mon, 22 Apr 2013 02:06:19 +0300	[thread overview]
Message-ID: <87ip3ffpqs.fsf@kepler.lan> (raw)
In-Reply-To: <874nf1k0je.fsf@kepler.lan> (Leonidas Tsampros's message of "Sat, 20 Apr 2013 12:35:01 +0300")

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

Leonidas Tsampros <ltsampros@upnet.gr> writes:
> Hello,
>
> long time no see :)
>
> TLDR: My Gmail inbox is full even after splitting mail. Here is why.
>

<snip>

That was easier than I thought. Please take a look at the patch attached
and send me your comments.

The changes can be described as such:

1. Add nnimap server user defined variable that defines whether the
server supports x-gm-ext-1 extension. Ideally this should come
from CAPABILITY string, but I wanted an explicit user knob for that.

2. Add nnimap-rfc822-date-to-imap4date that takes an rfc822 date value
and returns an imap4 datetime string (took the format from rfc3501).

3. Improve nnmail-split-incoming-mail so that if nnimap-x-gm-ext-1 is
defined for the current server, remove that fraking \\Inbox label from
the to be splitted mail. (Should this behaviour be configurable?)

4. Improve nnimap-request-accept-article so that it sets the
INTERNALDATE of the APPENDed message to the value of the message's date
header. (that's what I needed 2.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap x-gm-ext-1 improvement --]
[-- Type: text/x-patch, Size: 1816 bytes --]

=== modified file 'lisp/gnus/nnimap.el'
--- lisp/gnus/nnimap.el	2013-01-01 09:11:05 +0000
+++ lisp/gnus/nnimap.el	2013-04-21 23:04:35 +0000
@@ -66,6 +66,10 @@
 If nnimap-stream is `ssl', this will default to `imaps'.  If not,
 it will default to `imap'.")
 
+(defvoo nnimap-x-gm-ext-1 nil
+  "Defines whether this server supports the Gmail extensions
+  X-GM-EXT-1. Defaults to nil.")
+
 (defvoo nnimap-stream 'undecided
   "How nnimap talks to the IMAP server.
 The value should be either `undecided', `ssl' or `tls',
@@ -1060,6 +1064,7 @@
   (when (nnimap-possibly-change-group nil server)
     (nnmail-check-syntax)
     (let ((message-id (message-field-value "message-id"))
+	  (dt (message-field-value "date"))
 	  sequence message)
       (nnimap-add-cr)
       (setq message (buffer-substring-no-properties (point-min) (point-max)))
@@ -1072,7 +1077,8 @@
 	    (nnimap-unselect-group))
 	  (erase-buffer)
 	  (setq sequence (nnimap-send-command
-			  "APPEND %S {%d}" (utf7-encode group t)
+			  "APPEND %S %S {%d}" (utf7-encode group t)
+			  (nnimap-rfc822-date-to-imap4date dt)
 			  (length message)))
 	  (unless nnimap-streaming
 	    (nnimap-wait-for-connection "^[+]"))
@@ -1907,6 +1913,8 @@
 	(nnimap-fetch-inbox new-articles)
 	(nnimap-transform-split-mail)
 	(nnheader-ms-strip-cr)
+	(when nnimap-x-gm1-ext
+	  (nnimap-wait-for-response (nnimap-send-command "UID STORE %s -X-GM-LABELS (\\Inbox)" (nnimap-article-ranges new-articles))))
 	(nnmail-cache-open)
 	(nnmail-split-incoming (current-buffer)
 			       #'nnimap-save-mail-spec
@@ -2044,6 +2052,8 @@
 		   "(OR (OR HEADER Message-Id %S HEADER REFERENCES %S) %s)"
 		   refid refid value)))))
 
+(defun nnimap-rfc822-date-to-imap4date (datetime)
+  (format-time-string "%d-%b-%Y %H:%M:%S %z" (date-to-time datetime)))
 
 (provide 'nnimap)
 


  reply	other threads:[~2013-04-21 23:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-20  9:35 Leonidas Tsampros
2013-04-21 23:06 ` Leonidas Tsampros [this message]
2013-06-06 15:09   ` [PATCH] " Ted Zlatanov
2013-06-09 18:53     ` Leonidas Tsampros
2013-06-10  3:30       ` Ted Zlatanov
2013-06-10  5:46         ` Leonidas Tsampros
2013-06-10  6:28           ` Ted Zlatanov
2013-07-18  4:11             ` Leonidas Tsampros
2013-08-01 15:27               ` Lars Magne Ingebrigtsen
2013-08-01 16:22                 ` Leonidas Tsampros
2013-08-01 16:35                   ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ip3ffpqs.fsf@kepler.lan \
    --to=ltsampros@upnet.gr \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).