The previous one was repetitive, here is shorter version:
(defvar rcd-switch-to-buffer-list '("*scratch*" "*shell*" "*Messages*"))
(defun rcd-switch-to-buffer ()
(interactive)
(let ((buffers (mapcar (lambda (buffer) (get-buffer buffer))
rcd-switch-to-buffer-list)))
(if (member (current-buffer) buffers)
(when (buffer-live-p (next-circular-list-item buffers (current-buffer)))
(switch-to-buffer
(next-circular-list-item buffers (current-buffer))))
(when (buffer-live-p (get-buffer (nth 0 rcd-switch-to-buffer-list)))
(switch-to-buffer (nth 0 rcd-switch-to-buffer-list))))))
and you need this one:
(defun next-circular-list-item (list previous-item)
"Return the next element in the LIST by looking at PREVIOUS-ITEM.
All elements in the LIST have to be different.
If last element of LIST is equal to PREVIOUS-ITEM then first element is
returned."
(let ((last-element (car (last list))))
(cond ((eq last-element previous-item) (car list))
(t (nth 1 (member previous-item list))))))
Serendipity!It is more than I was looking for to roll my own,