* riece-filter.el (riece-sentinel): Close process even if
authorueno <ueno>
Sat, 31 May 2003 22:20:13 +0000 (22:20 +0000)
committerueno <ueno>
Sat, 31 May 2003 22:20:13 +0000 (22:20 +0000)
riece-reconnect-with-password == t.
(riece-handle-message): Catch errors occured in hooks.

* riece-server.el (riece-open-server): Reuse server buffer.
(riece-close-server-process): Delete process even if process is
not running.

* riece.el (riece): Don't set riece-server.

lisp/ChangeLog
lisp/riece-filter.el
lisp/riece-server.el
lisp/riece.el

index a6becef..b3c11a9 100644 (file)
@@ -1,5 +1,17 @@
 2003-05-31  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-filter.el (riece-sentinel): Close process even if
+       riece-reconnect-with-password == t.
+       (riece-handle-message): Catch errors occured in hooks.
+
+       * riece-server.el (riece-open-server): Reuse server buffer.
+       (riece-close-server-process): Delete process even if process is
+       not running.
+
+       * riece.el (riece): Don't set riece-server.
+
+2003-05-31  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-server.el (riece-open-server): No need to reset
        riece-reconnect-with-password.
 
index a2efcb3..432a018 100644 (file)
        (riece-parse-user-at-host (substring prefix (1+ (match-beginning 0))))))
   (setq message (downcase message)
        string (riece-decode-coding-string string))
-  (unless (run-hook-with-args-until-success
-          (intern (concat "riece-" message "-hook"))
-          prefix string)
-    (let ((function (intern-soft (concat "riece-handle-" message "-message"))))
+  (let ((function (intern-soft (concat "riece-handle-" message "-message")))
+       (hook (intern (concat "riece-" message "-hook")))
+       (after-hook (intern (concat "riece-after-" message "-hook"))))
+    (unless (condition-case error
+               (run-hook-with-args-until-success hook prefix string)
+             (error
+              (if riece-debug
+                  (message "Error occurred in `%S': %S" hook error))
+              nil))
       (if function
          (condition-case error
              (funcall function prefix string)
            (error
             (if riece-debug
-                (message "Error occurred in `%S': %S" function error))))))
-    (run-hook-with-args-until-success
-     (intern (concat "riece-after-" message "-hook"))
-     prefix string)))
+                (message "Error occurred in `%S': %S" function error)))))
+      (condition-case error
+         (run-hook-with-args-until-success after-hook prefix string)
+       (error
+        (if riece-debug
+            (message "Error occurred in `%S': %S" after-hook error)))))))
 
 (defun riece-filter (process input)
   (save-excursion
            (let* ((entry (rassq process riece-server-process-alist))
                   (server-name
                    (with-current-buffer (process-buffer process)
-                     riece-server-name))
-                  (process
-                   (riece-start-server
-                    (riece-server-name-to-server server-name)
-                    server-name)))
-             ;; Connect the process with old process' buffer.
-             (setcdr entry process)
-             (with-current-buffer (process-buffer process)
-               (setq riece-server-name server-name))))
+                     riece-server-name)))
+             (setcdr entry (riece-start-server
+                            (riece-server-name-to-server server-name)
+                            server-name))
+             (riece-close-server-process process)))
        (setq riece-reconnect-with-password nil))
     (let ((server-name (with-current-buffer (process-buffer process)
                         riece-server-name)))
index b149d38..b80d333 100644 (file)
@@ -112,19 +112,19 @@ the `riece-server-keyword-map' variable."
     (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
@@ -181,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"))
index 6af3b33..4885f9d 100644 (file)
@@ -254,11 +254,12 @@ If already connected, just pop up the windows."
     (switch-to-buffer (riece-get-buffer-create riece-command-buffer))
     (unless (eq major-mode 'riece-command-mode)
       (riece-command-mode))
-    (if (or confirm (null riece-server))
-       (setq riece-server (completing-read "Server: " riece-server-alist)))
-    (if (stringp riece-server)
-       (setq riece-server (riece-server-name-to-server riece-server)))
-    (setq riece-server-process (riece-start-server riece-server))
+    (let ((server-name
+          (if (or confirm (null riece-server))
+              (completing-read "Server: " riece-server-alist)
+            riece-server)))
+      (setq riece-server-process (riece-start-server
+                                 (riece-server-name-to-server server-name))))
     (riece-create-buffers)
     (riece-configure-windows)
     (let ((channel-list riece-startup-channel-list))