[gnus git] branch master updated: m0-9-36-g5a0a6cc =1= Download the Cloud chunks

Lars Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  5a0a6cc1fef60642ac30c3e24e06b8a45c994612 (commit)
      from  bdfcf8589cc0c5a7b3aa4f908048831f007bbe5e (commit)


- Log -----------------------------------------------------------------
commit 5a0a6cc1fef60642ac30c3e24e06b8a45c994612
Author: Lars Ingebrigtsen <[email protected]>
Date:   Tue Feb 4 19:16:31 2014 -0800

    Download the Cloud chunks
    
    * nnimap.el (nnimap-request-articles): New command to download several
    articles at once.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 40d6942..fa9bfae 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
 2014-02-05  Lars Ingebrigtsen  <[email protected]>
 
+	* nnimap.el (nnimap-request-articles): New command to download several
+	articles at once.
+
 	* gnus.el (gnus-variable-list): Save Cloud variables.
 
 	* gnus-int.el (gnus-request-accept-article): Doc fix.
diff --git a/lisp/gnus-cloud.el b/lisp/gnus-cloud.el
index f9f7fdc..9739f7c 100644
--- a/lisp/gnus-cloud.el
+++ b/lisp/gnus-cloud.el
@@ -26,6 +26,7 @@
 
 (eval-when-compile (require 'cl))
 (require 'parse-time)
+(require 'nnimap)
 
 (defgroup gnus-cloud nil
   "Syncing Gnus data via IMAP."
@@ -274,7 +275,10 @@
 	(while (and (not (eobp))
 		    (setq head (nnheader-parse-head)))
 	  (push head headers))))
-    (nreverse headers)))
+    (sort (nreverse headers)
+	  (lambda (h1 h2)
+	    (> (gnus-cloud-chunk-sequence (mail-header-subject h1))
+	       (gnus-cloud-chunk-sequence (mail-header-subject h2)))))))
 
 (defun gnus-cloud-chunk-sequence (string)
   (if (string-match "sequence: \\([0-9]+\\)" string)
@@ -282,11 +286,7 @@
     0))
 
 (defun gnus-cloud-prune-old-chunks (headers)
-  (let ((headers
-	 (sort (reverse headers)
-	       (lambda (h1 h2)
-		 (> (gnus-cloud-chunk-sequence (mail-header-subject h1))
-		    (gnus-cloud-chunk-sequence (mail-header-subject h2))))))
+  (let ((headers (reverse headers))
 	(found nil))
   (while (and headers
 	      (not found))
@@ -302,6 +302,22 @@
 	     (nreverse headers))
      (gnus-group-full-name gnus-cloud-group-name gnus-cloud-method)))))
 
+(defun gnus-cloud-download-data ()
+  (let ((articles nil)
+	chunks)
+    (dolist (header (gnus-cloud-available-chunks))
+      (when (> (gnus-cloud-chunk-sequence (mail-header-subject header))
+	       gnus-cloud-sequence)
+	(push (mail-header-number header) articles)))
+    (when articles
+      (nnimap-request-articles (nreverse articles) gnus-cloud-group-name)
+      (with-current-buffer nntp-server-buffer
+	(goto-char (point-min))
+	(while (re-search-forward "^Version " nil t)
+	  (beginning-of-line)
+	  (push (gnus-cloud-parse-chunk) chunks)
+	  (forward-line 1))))))
+
 (provide 'gnus-cloud)
 
 ;;; gnus-cloud.el ends here
diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index ff20075..d0b1d6c 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -624,6 +624,26 @@ textual parts.")
 	    (nnheader-ms-strip-cr)
 	    (cons group article)))))))
 
+(deffoo nnimap-request-articles (articles &optional group server)
+  (when group
+    (setq group (nnimap-decode-gnus-group group)))
+  (with-current-buffer nntp-server-buffer
+    (let ((result (nnimap-change-group group server)))
+      (when result
+	(erase-buffer)
+	(with-current-buffer (nnimap-buffer)
+	  (erase-buffer)
+	  (when (nnimap-command
+		 (if (nnimap-ver4-p)
+		     "UID FETCH %s BODY.PEEK[]"
+		   "UID FETCH %s RFC822.PEEK")
+		 (nnimap-article-ranges (gnus-compress-sequence articles)))
+	    (let ((buffer (current-buffer)))
+	      (with-current-buffer nntp-server-buffer
+		(nnheader-insert-buffer-substring buffer)
+		(nnheader-ms-strip-cr)))
+	    t))))))
+
 (defun nnimap-get-whole-article (article &optional command)
   (let ((result
 	 (nnimap-command

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog     |    3 +++
 lisp/gnus-cloud.el |   28 ++++++++++++++++++++++------
 lisp/nnimap.el     |   20 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 6 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.