Changes committed gnus/lisp (ChangeLog pop3.el)

"Ted Zlatanov" <[email protected]> Sat, 20 Mar 2010 17:19:52 +0100
Newsgroups gmane.emacs.gnus.commits
Message-ID <[email protected]>
Modified: ChangeLog pop3.el

(pop3-display-message-size-flag): Display message size byte
counts during POP3 download.
(pop3-movemail): Use it.
(pop3-list): Implement listing of available messages.


Index: ChangeLog
diff -u gnus/lisp/ChangeLog:7.2065 gnus/lisp/ChangeLog:7.2066
--- ChangeLog:7.2065	Sat Mar 20 17:02:30 2010
+++ ChangeLog	Sat Mar 20 17:19:52 2010
@@ -1,3 +1,10 @@
+2010-03-20  Bojan Petrovic <[email protected]>
+
+	* pop3.el (pop3-display-message-size-flag): Display message size byte
+	counts during POP3 download.
+	(pop3-movemail): Use it.
+	(pop3-list): Implement listing of available messages.
+
 2010-03-20  Mark Triggs <[email protected]> (tiny change)
 
 	* nnir.el (nnir-get-article-nov-override-function): New function to
Index: pop3.el
diff -u gnus/lisp/pop3.el:7.40 gnus/lisp/pop3.el:7.41
--- pop3.el:7.40	Wed Jan 13 11:59:44 2010
+++ pop3.el	Sat Mar 20 17:19:52 2010
@@ -98,6 +98,12 @@
   :type 'boolean
   :group 'pop3)
 
+(defcustom pop3-display-message-size-flag t
+  "*If non-nil, display the size of the message that is being fetched."
+  :version "22.1" ;; Oort Gnus
+  :type 'boolean
+  :group 'pop3) 
+
 (defvar pop3-timestamp nil
   "Timestamp returned when initially connected to the POP server.
 Used for APOP authentication.")
@@ -135,6 +141,7 @@
 	 (crashbuf (get-buffer-create " *pop3-retr*"))
 	 (n 1)
 	 message-count
+	 message-sizes
 	 (pop3-password pop3-password))
     ;; for debugging only
     (if pop3-debug (switch-to-buffer (process-buffer process)))
@@ -149,10 +156,18 @@
 	   (pop3-pass process))
 	  (t (error "Invalid POP3 authentication scheme")))
     (setq message-count (car (pop3-stat process)))
+    (when (and pop3-display-message-size-flag
+	       (> message-count 0))
+      (setq message-sizes (pop3-list process)))
     (unwind-protect
 	(while (<= n message-count)
-	  (message "Retrieving message %d of %d from %s..."
-		   n message-count pop3-mailhost)
+	  (if pop3-display-message-size-flag
+	      (message "Retrieving message %d of %d from %s... (%.1fk)"
+		       n message-count pop3-mailhost
+		       (/ (cdr (assoc n message-sizes))
+			  1024.0))
+	    (message "Retrieving message %d of %d from %s..."
+		     n message-count pop3-mailhost)) 	  
 	  (pop3-retr process n crashbuf)
 	  (save-excursion
 	    (set-buffer crashbuf)
@@ -451,8 +466,27 @@
     ))
 
 (defun pop3-list (process &optional msg)
-  "Scan listing of available messages.
-This function currently does nothing.")
+  "If MSG is nil, return an alist of (MESSAGE-ID . SIZE) pairs.
+Otherwise, return the size of the message-id MSG"
+  (pop3-send-command process (if msg 
+				 (format "LIST %d" msg)
+			       "LIST"))
+  (let ((response (pop3-read-response process t)))
+    (if msg
+	(string-to-number (nth 2 (split-string response " ")))
+      (let ((start pop3-read-point) end)
+	(save-excursion
+	  (set-buffer (process-buffer process))
+	  (while (not (re-search-forward "^\\.\r\n" nil t))
+	    (pop3-accept-process-output process)
+	    (goto-char start))
+	  (setq pop3-read-point (point-marker))
+	  (goto-char (match-beginning 0))
+	  (setq end (point-marker))
+	  (mapcar #'(lambda (s) (let ((split (split-string s " ")))
+				  (cons (string-to-number (nth 0 split))
+					(string-to-number (nth 1 split)))))
+		  (split-string (buffer-substring start end) "\r\n" t)))))))
 
 (defun pop3-retr (process msg crashbuf)
   "Retrieve message-id MSG to buffer CRASHBUF."