Path: utzoo!utgpu!water!watmath!uunet!bu-cs!bloom-beacon!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!gildea From: gildea@ALEXANDER.BBN.COM (Stephen Gildea) Newsgroups: gnu.emacs.bug Subject: a buffer ring Message-ID: <8809291851.AA08476@prep.ai.mit.edu> Date: 29 Sep 88 19:23:47 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 29 Here is a function that allows you to run through all your buffers. Give it an explicit argument of 1. I usually use it for returning to recently-visited buffers with an argument of 2 (the default) or 3. < Stephen (defun switch-to-previous-buffer (n) "Switch to Nth previously selected buffer. N defaults to 2, which switches to the most recently selected buffer. If N is 1, repeated calls will cycle through all buffers, otherwise the first N buffers on the buffer list are rotated. gildea Sep 88" (interactive "P") (if (not n) (setq n 2) (setq n (prefix-numeric-value n))) (if (= n 1) (progn (bury-buffer (current-buffer)) (setq n 2))) (let ((buffer-list (buffer-list))) (while (and (> n 1) buffer-list) (setq n (1- n)) (setq buffer-list (cdr buffer-list)) (while (eq (elt (buffer-name (car buffer-list)) 0) ? ) (setq buffer-list (cdr buffer-list)))) (if buffer-list (switch-to-buffer (car buffer-list)) (error "There aren't that many buffers"))))