* riece-filter.el (riece-sentinel): Close process even if
[riece] / lisp / riece-server.el
index 4d5b244..b80d333 100644 (file)
@@ -64,9 +64,6 @@ the `riece-server-keyword-map' variable."
 (put 'riece-server-keyword-bind 'edebug-form-spec '(form body))
 
 (defun riece-start-server (server &optional server-name)
-  "Open network stream to remote irc server.
-If optional argument CONFIRM is non-nil, ask the host that the server
-is running on."
   (if server-name
       (message "Connecting to IRC server on %s..." server-name)
     (message "Connecting to IRC server..."))
@@ -115,19 +112,19 @@ is running on."
     (cdr entry)))
 
 (defun riece-open-server (server server-name)
-  "Open chat server on HOST.
-If HOST is nil, use value of environment variable \"IRCSERVER\".
-If optional argument SERVICE is non-nil, open by the service name."
   (riece-server-keyword-bind server
     (let* (selective-display
           (coding-system-for-read 'binary)
           (coding-system-for-write 'binary)
           (process
-           (funcall function "IRC" (if server-name
-                                       (format " *IRC*%s" server-name)
-                                     " *IRC*")
+           (funcall function "IRC"
+                    (get-buffer-create
+                     (if server-name
+                         (format " *IRC*%s" server-name)
+                       " *IRC*"))
                     host service)))
       (riece-reset-process-buffer process)
+      (setq riece-server-name server-name)
       (set-process-sentinel process 'riece-sentinel)
       (set-process-filter process 'riece-filter)
       (if (or password
@@ -137,7 +134,6 @@ If optional argument SERVICE is non-nil, open by the service name."
                                             (or password
                                                 (riece-read-passwd
                                                  "Password: ")))))
-      (setq riece-reconnect-with-password nil)
       (riece-process-send-string process
                                 (format "USER %s * * :%s\r\n"
                                         (user-real-login-name)
@@ -185,9 +181,9 @@ If optional argument SERVICE is non-nil, open by the service name."
                               (if quit-message
                                   (format "QUIT :%s\r\n" quit-message)
                                 "QUIT\r\n"))
-    (delete-process process)
     (unless riece-debug
-      (kill-buffer (process-buffer process)))))
+      (kill-buffer (process-buffer process))))
+  (delete-process process))
 
 (eval-when-compile
   (autoload 'riece-exit "riece"))
@@ -196,8 +192,9 @@ If optional argument SERVICE is non-nil, open by the service name."
   (let ((riece-overriding-server-name server-name)
        (channels riece-current-channels))
     (while channels
-      (if (equal (riece-identity-server (car channels))
-                server-name)
+      (if (and (car channels)
+              (equal (riece-identity-server (car channels))
+                     server-name))
          (riece-part-channel (car channels)))
       (setq channels (cdr channels)))
     (riece-redisplay-buffers))