(cf. the last paragraph of `kill-buffer' docstring)
[riece] / lisp / riece-server.el
index e0d3742..20aedf8 100644 (file)
@@ -39,7 +39,7 @@
       (:username riece-username)
       (:password)
       (:function #'open-network-stream)
-      (:coding-system riece-default-coding-system))
+      (:coding riece-default-coding-system))
     "Mapping from keywords to default values.
 All keywords that can be used must be listed here."))
 
@@ -104,7 +104,7 @@ the `riece-server-keyword-map' variable."
 
 (defun riece-open-server (server &optional server-name)
   (if server-name
-      (message "Connecting to IRC server on %s..." server-name)
+      (message "Connecting to %s..." server-name)
     (message "Connecting to IRC server..."))
   (riece-server-keyword-bind server
     (let* (selective-display
@@ -112,13 +112,13 @@ the `riece-server-keyword-map' variable."
           (coding-system-for-write 'binary)
           (process
            (funcall function "IRC"
-                    (get-buffer-create
-                     (if server-name
-                         (format " *IRC*%s" server-name)
-                       " *IRC*"))
+                    (if server-name
+                        (format " *IRC*%s" server-name)
+                      " *IRC*")
                     host service)))
       (riece-reset-process-buffer process)
-      (setq riece-server-name server-name)
+      (with-current-buffer (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,14 +137,14 @@ the `riece-server-keyword-map' variable."
       (with-current-buffer (process-buffer process)
        (setq riece-last-nickname riece-real-nickname
              riece-nick-accepted 'sent
-             riece-coding-system coding-system))
+             riece-coding-system coding))
       (if server-name
          (setq riece-server-process-alist
                (cons (cons server-name process)
                      riece-server-process-alist))
        (setq riece-server-process process))))
   (if server-name
-      (message "Connecting to IRC server on %s...done" server-name)
+      (message "Connecting to %s...done" server-name)
     (message "Connecting to IRC server...done")))
 
 (defun riece-reset-process-buffer (process)
@@ -177,14 +177,14 @@ the `riece-server-keyword-map' variable."
       (set-process-filter process nil))
   (if (eq 'riece-sentinel (process-sentinel process))
       (set-process-sentinel process nil))
-  (when (memq (process-status process) '(open run))
-    (riece-process-send-string process
-                              (if quit-message
-                                  (format "QUIT :%s\r\n" quit-message)
-                                "QUIT\r\n"))
-    (unless riece-debug
-      (kill-buffer (process-buffer process))))
-  (delete-process process))
+  (if (memq (process-status process) '(open run))
+      (riece-process-send-string process
+                                (if quit-message
+                                    (format "QUIT :%s\r\n" quit-message)
+                                  "QUIT\r\n")))
+  (if riece-debug
+      (delete-process process)
+    (kill-buffer (process-buffer process))))
 
 (eval-when-compile
   (autoload 'riece-exit "riece"))