+ (t (error "Invalid POP3 authentication scheme")))
+ (setq message-count (car (pop3-stat process)))
+ (unwind-protect
+ (while (<= n message-count)
+ (message "Retrieving message %d of %d from %s..."
+ n message-count pop3-mailhost)
+ (pop3-retr process n crashbuf)
+ (save-excursion
+ (set-buffer crashbuf)
+ (let ((coding-system-for-write 'binary))
+ (write-region (point-min) (point-max) crashbox t 'nomesg))
+ (set-buffer (process-buffer process))
+ (while (> (buffer-size) 5000)
+ (goto-char (point-min))
+ (forward-line 50)
+ (delete-region (point-min) (point))))
+ (unless pop3-leave-mail-on-server
+ (pop3-dele process n))
+ (setq n (+ 1 n))
+ (if pop3-debug (sit-for 1) (sit-for 0.1))) ; why?
+ (pop3-quit process))
+ (kill-buffer crashbuf))
+ t)
+
+(defun pop3-get-message-count ()
+ "Return the number of messages in the maildrop."
+ (let* ((process (pop3-open-server pop3-mailhost pop3-port))
+ message-count
+ (pop3-password pop3-password))
+ ;; for debugging only
+ (if pop3-debug (switch-to-buffer (process-buffer process)))
+ ;; query for password
+ (if (and pop3-password-required (not pop3-password))
+ (setq pop3-password
+ (read-passwd (format "Password for %s: " pop3-maildrop))))
+ (cond ((equal 'apop pop3-authentication-scheme)
+ (pop3-apop process pop3-maildrop))
+ ((equal 'pass pop3-authentication-scheme)
+ (pop3-user process pop3-maildrop)
+ (pop3-pass process))
+ (t (error "Invalid POP3 authentication scheme")))