+2003-11-05  OHASHI Akira  <bg66@koka-in.org>
+
+       * riece-unread.el (riece-unread-switch-to-channel): Protect
+       switching to the channel not existing.
+
 2003-10-29  OHASHI Akira  <bg66@koka-in.org>
 
        * riece-log.el (riece-log-get-directory): Support riece-identity
-        for mapping.
+       for mapping.
 
 2003-10-28  Daiki Ueno  <ueno@unixuser.org>
 
 
 
 (defun riece-unread-switch-to-channel ()
   (interactive)
-  (if (car riece-unread-channels)
-      (riece-command-switch-to-channel (car riece-unread-channels))
+  (if riece-unread-channels
+      (let ((channel (car riece-unread-channels)))
+       (if (riece-identity-member channel riece-current-channels)
+           (riece-command-switch-to-channel channel)
+         (setq riece-unread-channels
+               (delete channel riece-unread-channels))
+         (riece-unread-switch-to-channel)))
     (error "No unread channel!")))
 
 (defun riece-guess-channel-from-unread ()