pop3.el (pop3-wait-for-messages): Fix retrieved data size calculation.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 25 Apr 2012 11:19:25 +0000 (11:19 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 25 Apr 2012 11:19:25 +0000 (11:19 +0000)
lisp/ChangeLog
lisp/pop3.el

index cf92175..11c1aff 100644 (file)
@@ -1,3 +1,7 @@
+2012-04-25  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * pop3.el (pop3-wait-for-messages): Fix retrieved data size calculation.
+
 2012-04-19  Juanma Barranquero  <lekktu@gmail.com>
 
        * tls.el (open-tls-stream): Remove unused binding.
index ee4345c..2533098 100644 (file)
@@ -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)