home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.emacs
- Path: sparky!uunet!haven.umd.edu!purdue!ames!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!Germany.EU.net!ubrinf!mathematik.uni-Bremen.de!bengt
- From: bengt@mathematik.uni-Bremen.de (Bengt Martensson)
- Subject: Re: anyone got a way to cycle through buffers with a keystroke?
- Message-ID: <1992Nov6.145015.23357@informatik.uni-bremen.de>
- Sender: news@informatik.uni-bremen.de (NEWS Service)
- Nntp-Posting-Host: athena
- Organization: University of Bremen, Germany
- References: <EJH.92Nov4132905@khonshu.colorado.edu>
- Date: Fri, 6 Nov 1992 14:50:15 GMT
- Lines: 38
-
- In article <EJH.92Nov4132905@khonshu.colorado.edu>, 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 Hartnett ejh@khonshu.colorado.edu
- |>
-
- The following should do exactly what you want. I wrote it a few years ago.
-
-
- (defun switch-to-another-buffer ()
- "Cycles around the buffers in the current window."
- (interactive)
- (setq the-buffer-list (if (equal last-command 'switch-to-another-buffer)
- the-buffer-list
- (cdr (setq the-old-buffer-list (buffer-list)))))
- (let ((b nil)
- (name ""))
- (while (or (equal name "") (= (aref name 0) ? ))
- (setq b (car the-buffer-list))
- (setq name (buffer-name b))
- (setq the-buffer-list (if (cdr the-buffer-list)
- (cdr the-buffer-list)
- the-old-buffer-list)))
- (switch-to-buffer b)))
-
- --
- Bengt Martensson +49 421 218-2952 (office)
- Institute for Dynamical Systems +49 421 17 17 13 (home)
- University of Bremen +49 421 218-4235 (fax)
- P.O. Box 330 440, D-2800 Bremen 33, Germany bengt@mathematik.uni-Bremen.de
-