Merge from emacs--devo--0
[gnus] / lisp / pop3.el
index eeb7d70..8206c4d 100644 (file)
@@ -1,7 +1,7 @@
 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface
 
 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Richard L. Pieri <ratinox@peorth.gweep.net>
 ;; Maintainer: FSF
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -36,6 +34,7 @@
 ;;; Code:
 
 (require 'mail-utils)
+(defvar parse-time-months)
 
 (defgroup pop3 nil
   "Post Office Protocol."
@@ -212,7 +211,7 @@ SSL/TSL-secured stream) or `starttls' (use the starttls mechanism
 to turn on TLS security after opening the stream).  However, if
 this is nil, `ssl' is assumed for connexions to port
 995 (pop3s)."
-  :version "23.0" ;; No Gnus
+  :version "23.1" ;; No Gnus
   :group 'pop3
   :type '(choice (const :tag "Plain" nil)
                 (const :tag "SSL/TLS" ssl)
@@ -241,16 +240,23 @@ Returns the process associated with the connection."
                                              mailhost port)))
                (when process
                  ;; There's a load of info printed that needs deleting.
-                 (while (when (memq (process-status process) '(open run))
-                          (pop3-accept-process-output process)
-                          (goto-char (point-max))
-                          (forward-line -1)
-                          (if (looking-at "\\+OK")
-                              (progn
-                                (delete-region (point-min) (point))
-                                nil)
+                 (let ((again 't))
+                   ;; repeat until
+                   ;; - either we received the +OK line
+                   ;; - or accept-process-output timed out without getting
+                   ;;   anything
+                   (while (and again
+                               (setq again (memq (process-status process)
+                                                 '(open run))))
+                     (setq again (pop3-accept-process-output process))
+                     (goto-char (point-max))
+                     (forward-line -1)
+                     (cond ((looking-at "\\+OK")
+                            (setq again nil)
+                            (delete-region (point-min) (point)))
+                           ((not again)
                             (pop3-quit process)
-                            (error "POP SSL connexion failed"))))
+                            (error "POP SSL connexion failed")))))
                  process)))
             ((eq pop3-stream-type 'starttls)
              ;; gnutls-cli, openssl don't accept service names
@@ -306,7 +312,7 @@ Return the response string if optional second argument is non-nil."
       (setq match-end (point))
       (goto-char pop3-read-point)
       (if (looking-at "-ERR")
-         (error (buffer-substring (point) (- match-end 2)))
+         (error "%s" (buffer-substring (point) (- match-end 2)))
        (if (not (looking-at "+OK"))
            (progn (setq pop3-read-point match-end) nil)
          (setq pop3-read-point match-end)
@@ -327,8 +333,6 @@ Return the response string if optional second argument is non-nil."
       (forward-char)))
   (set-marker end nil))
 
-(eval-when-compile (defvar parse-time-months))
-
 ;; Copied from message-make-date.
 (defun pop3-make-date (&optional now)
   "Make a valid date header.
@@ -607,5 +611,5 @@ and close the connection."
 
 (provide 'pop3)
 
-;;; arch-tag: 2facc142-1d74-498e-82af-4659b64cac12
+;; arch-tag: 2facc142-1d74-498e-82af-4659b64cac12
 ;;; pop3.el ends here