Make `gnus-msg-mail' warn about Gnus not running
[gnus] / lisp / pop3.el
index 0f7a450..2533098 100644 (file)
@@ -1,6 +1,6 @@
 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface
 
-;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
 
 ;; Author: Richard L. Pieri <ratinox@peorth.gweep.net>
 ;; Maintainer: FSF
@@ -194,10 +194,16 @@ Use streaming commands."
     (unless (memq (process-status process) '(open run))
       (error "pop3 process died"))
     (when total-size
-      (message "pop3 retrieved %dKB (%d%%)"
-              (truncate (/ (buffer-size) 1000))
-              (truncate (* (/ (* (buffer-size) 1.0)
-                              total-size) 100))))
+      (let ((size 0))
+       (goto-char (point-min))
+       (while (re-search-forward "^\\+OK.*\n" nil t)
+         (setq size (+ size (- (point))
+                       (if (re-search-forward "^\\.\r?\n" nil 'move)
+                           (match-beginning 0)
+                         (point)))))
+       (message "pop3 retrieved %dKB (%d%%)"
+                (truncate (/ size 1000))
+                (truncate (* (/ (* size 1.0) total-size) 100)))))
     (pop3-accept-process-output process))
   start-point)