(require 'iswitchb) (defvar next-buffer-depth 0) (defun next-buffer () (interactive) (let (buflist len buf) ;; This is a stripped down version of `iswitchb-make-buflist'. ;; I want to use `iswitchb-ignore-buffername-p' instead of ;; duplicating the work. (setq buflist (delq nil (mapcar (lambda (x) (let ((b-name (buffer-name x))) (unless (iswitchb-ignore-buffername-p b-name) b-name))) (buffer-list)))) ;; However, I do not want the current buffer in the list (setq buflist (delq (buffer-name) buflist)) (if (eq last-command 'next-buffer) (progn (setq len (1- (list-length buflist))) (if (eq next-buffer-depth len) ;; Just keep taking the tail of the list (setq buf (nth next-buffer-depth buflist)) (progn (setq next-buffer-depth (1+ next-buffer-depth)) (setq buf (nth next-buffer-depth buflist))))) ;; This is the first next-buffer (setq next-buffer-depth 0) (setq buf (car buflist))) (if (not buf) (error "No other buffers")) (switch-to-buffer buf))) (global-set-key [f11] 'next-buffer)