From c6029b2eae0018343a829fc745b71fd8d068d966 Mon Sep 17 00:00:00 2001 From: ueno Date: Sat, 31 May 2003 01:16:50 +0000 Subject: [PATCH] * riece-commands.el (riece-command-next-channel): Circularly follow the channel list. (riece-command-previous-channel): Ditto. --- lisp/ChangeLog | 4 ++++ lisp/riece-commands.el | 33 ++++++++++++--------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4def359..981dc49 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2003-05-31 Daiki Ueno + * riece-commands.el (riece-command-next-channel): Circularly + follow the channel list. + (riece-command-previous-channel): Ditto. + * riece-url.el: Fix usage. * riece-inlines.el (string-list-member-ignore-case): Remove docstring. diff --git a/lisp/riece-commands.el b/lisp/riece-commands.el index a70f4dc..004490f 100644 --- a/lisp/riece-commands.el +++ b/lisp/riece-commands.el @@ -72,31 +72,22 @@ (defun riece-command-next-channel () "Select the next channel." (interactive) - (let ((pointer (cdr (string-list-member-ignore-case - riece-current-channel - riece-current-channels)))) - (while (and pointer - (null (car pointer))) - (setq pointer (cdr pointer))) - (if (car pointer) - (riece-command-switch-to-channel (car pointer)) - (error "No such channel!")))) + (when (> (length riece-current-channels) 1) + (let ((channels (copy-sequence riece-current-channels))) + (setcdr (last channels) channels) ;make a circular link + (riece-command-switch-to-channel + (nth 1 (string-list-member-ignore-case + riece-current-channel channels)))))) (defun riece-command-previous-channel () "Select the previous channel." (interactive) - (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 ((channels (nreverse (copy-sequence riece-current-channels)))) + (setcdr (last channels) channels) ;make a circular link + (riece-command-switch-to-channel + (nth 1 (string-list-member-ignore-case + riece-current-channel channels)))))) (defun riece-command-select-command-buffer () "Select the command buffer." -- 1.7.10.4