Fix my last change.
[gnus] / lisp / nntp.el
index 3a2d90b..6044c93 100644 (file)
@@ -1,5 +1,7 @@
 ;;; nntp.el --- nntp access for Gnus
-;;; Copyright (C) 1987-90,92-99 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993, 1994, 1995, 1996,
+;;        1997, 1998, 2000
+;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -178,7 +180,8 @@ server there that you can connect to.  See also
 
 (defvoo nntp-connection-timeout nil
   "*Number of seconds to wait before an nntp connection times out.
-If this variable is nil, which is the default, no timers are set.")
+If this variable is nil, which is the default, no timers are set.
+NOTE: This variable is never seen to work in FSF Emacs 20 and XEmacs 21.")
 
 ;;; Internal variables.
 
@@ -334,17 +337,26 @@ noticing asynchronous data.")
        (save-excursion
          (set-buffer (process-buffer process))
          (erase-buffer)))
-      (when command
-       (nntp-send-string process command))
-      (cond
-       ((eq callback 'ignore)
-       t)
-       ((and callback wait-for)
-       (nntp-async-wait process wait-for buffer decode callback)
-       t)
-       (wait-for
-       (nntp-wait-for process wait-for buffer decode))
-       (t t)))))
+      (condition-case err
+         (progn
+           (when command
+             (nntp-send-string process command))
+           (cond
+            ((eq callback 'ignore)
+             t)
+            ((and callback wait-for)
+             (nntp-async-wait process wait-for buffer decode callback)
+             t)
+            (wait-for
+             (nntp-wait-for process wait-for buffer decode))
+            (t t)))
+       (error 
+        (nnheader-report 'nntp "Couldn't open connection to %s: %s" 
+                         address err))
+       (quit
+        (message "Quit retrieving data from nntp")
+        (signal 'quit nil)
+        nil)))))
 
 (defsubst nntp-send-command (wait-for &rest strings)
   "Send STRINGS to server and wait until WAIT-FOR returns."
@@ -775,7 +787,7 @@ and a password.
 If SEND-IF-FORCE, only send authinfo to the server if the
 .authinfo file has the FORCE token."
   (let* ((list (gnus-parse-netrc nntp-authinfo-file))
-        (alist (gnus-netrc-machine list nntp-address))
+        (alist (gnus-netrc-machine list nntp-address "nntp"))
         (force (gnus-netrc-get alist "force"))
         (user (or (gnus-netrc-get alist "login") nntp-authinfo-user))
         (passwd (gnus-netrc-get alist "password")))
@@ -792,8 +804,9 @@ If SEND-IF-FORCE, only send authinfo to the server if the
           (or passwd
               nntp-authinfo-password
               (setq nntp-authinfo-password
-                    (mail-source-read-passwd (format "NNTP (%s@%s) password: "
-                                                     user nntp-address))))))))))
+                    (mail-source-read-passwd
+                     (format "NNTP (%s@%s) password: "
+                             user nntp-address))))))))))
 
 (defun nntp-send-nosy-authinfo ()
   "Send the AUTHINFO to the nntp server."
@@ -865,7 +878,11 @@ password contained in '~/.nntp-authinfo'."
                     (coding-system-for-write nntp-coding-system-for-write))
                (funcall nntp-open-connection-function pbuffer))
            (error nil)
-           (quit nil))))
+           (quit
+            (message "Quit opening connection")
+            (nntp-kill-buffer pbuffer)
+            (signal 'quit nil)
+            nil))))
     (when timer
       (nnheader-cancel-timer timer))
     (when (and (buffer-name pbuffer)
@@ -974,7 +991,7 @@ password contained in '~/.nntp-authinfo'."
       (if (memq (following-char) '(?4 ?5))
          ;; wants credentials?
          (if (looking-at "480")
-             (nntp-handle-authinfo nntp-process-to-buffer)
+             (nntp-handle-authinfo process)
            ;; report error message.
            (nntp-snarf-error-message)
            (nntp-do-callback nil))
@@ -1181,7 +1198,8 @@ password contained in '~/.nntp-authinfo'."
          (goto-char (point-max))
          (while (not (re-search-backward "^[0-9][0-9][0-9] " nil t))
            (nntp-accept-response)
-           (set-buffer process-buffer))
+           (set-buffer process-buffer)
+           (goto-char (point-max)))
          (when (looking-at "^[23]")
            (while (progn
                     (goto-char (point-max))
@@ -1263,6 +1281,7 @@ password contained in '~/.nntp-authinfo'."
                 "nntpd" buffer nntp-telnet-command nntp-telnet-switches))
          (case-fold-search t))
       (when (memq (process-status proc) '(open run))
+       (nntp-wait-for-string "^r?telnet")
        (process-send-string proc "set escape \^X\n")
        (cond
         ((and nntp-open-telnet-envuser nntp-telnet-user-name)
@@ -1292,7 +1311,7 @@ password contained in '~/.nntp-authinfo'."
        (beginning-of-line)
        (delete-region (point-min) (point))
        (process-send-string proc "\^]")
-       (nntp-wait-for-string "^telnet")
+       (nntp-wait-for-string "^r?telnet")
        (process-send-string proc "mode character\n")
        (accept-process-output proc 1)
        (sit-for 1)