Subject: bug#5650: Proposed fix

From: Vivek Dasmohapatra <[email-masked]>
Date: Fri, 26 Feb 2010 23:49:50 +0000 (GMT)

Does this patch fix things for you?
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -362,7 +362,7 @@ alist."
   :type '(repeat (cons (string :tag "Target")
                        coding-system)))
 
-(defcustom erc-server-connect-function 'open-network-stream
+(defcustom erc-server-connect-function 'erc-open-network-stream
   "Function used to initiate a connection.
 It should take same arguments as `open-network-stream' does."
   :group 'erc-server
@@ -483,6 +483,10 @@ The current buffer is given by BUFFER."
        (memq (process-status erc-server-process) '(run open))))
 
 ;;;; Connecting to a server
+(defun erc-open-network-stream (name buffer host service)
+  "As `open-network-stream', but does non-blocking IO"
+  (make-network-process :name name :buffer  buffer
+                        :host host :service service :nowait t))
 
 (defun erc-server-connect (server port buffer)
   "Perform the connection and login using the specified SERVER and PORT.
@@ -523,9 +527,8 @@ We will store server variables in the buffer given by BUFFER."
             (with-current-buffer buffer (erc-current-nick))))
   ;; wait with script loading until we receive a confirmation (first
   ;; MOTD line)
-  (if (eq erc-server-connect-function 'open-network-stream-nowait)
-      ;; it's a bit unclear otherwise that it's attempting to establish a
-      ;; connection
+  (if (eq (process-status process) 'connect)
+      ;; waiting for anon-blocking connect - keep the user informed
       (erc-display-message nil nil buffer "Opening connection..\n")
     (erc-login)))
 
@@ -543,7 +546,7 @@ Make sure you are in an ERC buffer when running this."
       (setq erc-server-last-sent-time 0)
       (setq erc-server-lines-sent 0)
       (let ((erc-server-connect-function (or erc-session-connector
-                                             'open-network-stream)))
+                                             'erc-open-network-stream)))
         (erc-open erc-session-server erc-session-port erc-server-current-nick
                   erc-session-user-full-name t erc-session-password)))))