- (let ((pointer (string-list-member-ignore-case
- riece-current-channel
- riece-current-channels))
- (start riece-current-channels)
- channel)
- (while (and start (not (eq start pointer)))
- (if (car start)
- (setq channel (car start)))
- (setq start (cdr start)))
- (if channel
- (riece-command-switch-to-channel channel)
- (error "No such channel!"))))
+ (when (> (length riece-current-channels) 1)
+ (let ((pointer (riece-identity-member-no-server
+ riece-current-channel
+ riece-current-channels))
+ (start riece-current-channels)
+ channel)
+ (while (and start (not (eq start pointer)))
+ (setq channel (car start))
+ (setq start (cdr start)))
+ (when (null channel)
+ (setq start (copy-sequence riece-current-channels))
+ (setq start (delq nil start))
+ (and (> (length start) 1)
+ (setq channel (nth (1- (length start)) start))))
+ (if channel
+ (riece-command-switch-to-channel channel)
+ (error "No such channel!")))))