home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.emacs
- Path: sparky!uunet!gatech!news.byu.edu!hamblin.math.byu.edu!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: anyone got a way to cycle through buffers with a keystroke?
- Message-ID: <mcook.720989949@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <EJH.92Nov4132905@khonshu.colorado.edu>
- Date: Thu, 5 Nov 1992 18:59:09 GMT
- Lines: 36
-
- ejh@khonshu.colorado.edu (Edward J. Hartnett) writes:
-
- >Hi. I often have maybe 5 or 10 programs and other files open at once, and
- >switch back and forth more or less randomly. It's very annoying that I have
- >to tyep out the buffer name I want each time (even with tab completion). Does
- >anyone out there have any elisp code that would allow me to cycle through the
- >buffers with a keystroke? So I'd hit a key and the buffer would switch to the
- >next one, then again and it would go to the next, etc. Then I could just pop
- >pop pop on the key until the buffer I wanted came up. -- Edward
-
- Here what I use:
-
- (defvar cycle-buffers nil
- "List of buffers we've cycled through so far.")
-
- (defun cycle-buffer ()
- "Switch to another buffer."
- (interactive)
- (or (eq last-command this-command)
- (setq cycle-buffers nil))
- (let ((list (buffer-list)))
- (setq cycle-buffers (cons (car list) cycle-buffers))
- (while (or (and list
- (let ((name (buffer-name (car list))))
- (or (string-equal name "")
- (= (aref name 0) ? ))))
- (memq (car list) cycle-buffers))
- (setq list (cdr list)))
- (switch-to-buffer (or (car list)
- (other-buffer)))))
-
- Bind it to a key, then each time you press that key, it shows you another
- buffer. If you press any other keys in between, it'll start from the
- beginning of the buffer list again.
-
- Michael.
-