home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / emacs / 3473 < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.3 KB  |  51 lines

  1. Newsgroups: comp.emacs
  2. 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
  3. From: bengt@mathematik.uni-Bremen.de (Bengt Martensson)
  4. Subject: Re: anyone got a way to cycle through buffers with a keystroke?
  5. Message-ID: <1992Nov6.145015.23357@informatik.uni-bremen.de>
  6. Sender: news@informatik.uni-bremen.de (NEWS Service)
  7. Nntp-Posting-Host: athena
  8. Organization: University of Bremen, Germany
  9. References:  <EJH.92Nov4132905@khonshu.colorado.edu>
  10. Date: Fri, 6 Nov 1992 14:50:15 GMT
  11. Lines: 38
  12.  
  13. In article <EJH.92Nov4132905@khonshu.colorado.edu>, ejh@khonshu.colorado.edu (Edward J. Hartnett) writes:
  14. |> 
  15. |> Hi. I often have maybe 5 or 10 programs and other files open at once,
  16. |> and switch back and forth more or less randomly. It's very annoying
  17. |> that I have to tyep out the buffer name I want each time (even with
  18. |> tab completion). Does anyone out there have any elisp code that would
  19. |> allow me to cycle through the buffers with a keystroke? So I'd hit a
  20. |> key and the buffer would switch to the next one, then again and it
  21. |> would go to the next, etc. Then I could just pop pop pop on the key
  22. |> until the buffer I wanted came up.
  23. |> --
  24. |> Edward Hartnett            ejh@khonshu.colorado.edu
  25. |> 
  26.  
  27. The following should do exactly what you want. I wrote it a few years ago.
  28.  
  29.  
  30. (defun switch-to-another-buffer ()
  31.   "Cycles around the buffers in the current window."
  32.   (interactive)
  33.   (setq the-buffer-list (if (equal last-command 'switch-to-another-buffer)
  34.                 the-buffer-list
  35.                    (cdr (setq the-old-buffer-list (buffer-list)))))
  36.   (let ((b nil)
  37.     (name ""))
  38.     (while (or (equal name "")  (= (aref name 0) ? ))
  39.       (setq b (car the-buffer-list))
  40.       (setq name (buffer-name b))
  41.       (setq the-buffer-list (if (cdr the-buffer-list)
  42.                 (cdr the-buffer-list)
  43.                   the-old-buffer-list)))
  44.     (switch-to-buffer b)))
  45.  
  46. -- 
  47. Bengt Martensson                                +49 421 218-2952 (office)
  48. Institute for Dynamical Systems                 +49 421 17 17 13 (home)
  49. University of Bremen                            +49 421 218-4235 (fax)
  50. P.O. Box 330 440, D-2800 Bremen 33, Germany     bengt@mathematik.uni-Bremen.de
  51.