home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.emacs
- Path: sparky!uunet!pmafire!mica.inel.gov!ux1!news.byu.edu!eff!iWarp.intel.com|ichips!pdx025!jabram
- From: jabram@pdx025 (Jeff Abramson)
- Subject: Re: anyone got a way to cycle through buffers with a keystroke?
- Message-ID: <1992Nov6.162055.29554@ichips.intel.com>
- Sender: news@ichips.intel.com (News Account)
- Organization: Intel Corp., Hillsboro, Oregon
- References: <EJH.92Nov4132905@khonshu.colorado.edu> <Bx94Fp.3t5@da_vinci.it.uswc.uswest.com>
- Distribution: usa
- Date: Fri, 6 Nov 1992 16:20:55 GMT
- Lines: 84
-
- I've seen some good options on how to do this, but I wrote my own
- functions to work with a specific list of buffers, not the entire buffer list.
-
- Below is a list definition, and four subroutines: The first loads all the
- named files into buffers. The second saves them with a single keystroke.
- The third and fourth cycle through the list.
-
- This is really the first set of emacs functions I have written, and they seem
- to be working out well for me. So there is probably a better way to do it,
- but isn't that always the case...
-
-
- (defvar foo-buffer-list
- (list
- "foo.hdl"
- "fooa.hdl"
- "foob.hdl"
- "fooc.hdl"
- "food.hdl"
- "fooe.hdl"
- "foof.hdl"))
-
- ;; saves all files in foo-buffer-list
- ;;
- (global-set-key "\C-x\C-m" 'save-all-foo-hdl-file)
- (defun save-all-foo-hdl-file ()
- (interactive)
- (dotimes (i (length foo-buffer-list))
- (set-buffer (nth i foo-buffer-list))
- (save-buffer)))
-
- ;; loads all files in foo-buffer-list
- ;;
- (defun load-all-foo-hdl-files ()
- (interactive)
- (dotimes (i (length foo-buffer-list))
- (find-file (nth i foo-buffer-list))))
-
-
- ;; These two defuns allow me to move around in the foo-buffer-list easily.
- ;;
- ;; Bound to M-p and M-n.
- ;;
- (global-set-key "≡" 'foo-prev-buffer)
- (global-set-key "ε" 'foo-next-buffer)
-
- (defun foo-next-buffer ()
- "Switch to next buffer in foo list. Basically, split
- the list at that buffer, and move the sublist from that
- buffer to the end of the list, to the beginning
-
- (foo-next-buffer) does:
- (a b c d e) --> (b c d e a)"
-
- (interactive)
- (setq foo-buffer-list
- (append (cdr foo-buffer-list)
- (list (car foo-buffer-list))))
- (switch-to-buffer (car foo-buffer-list)))
-
- (defun foo-prev-buffer ()
- "Switch to next buffer in foo list. Basically, split
- the list at that buffer, and move the sublist from that
- buffer to the end of the list, to the beginning
-
- (foo-next-buffer) does:
- (a b c d e) --> (e a b c d)"
-
- (interactive)
- (let ((last (nth (- (length foo-buffer-list) 1) foo-buffer-list))
- (rest (delq (nth (- (length foo-buffer-list) 1) foo-buffer-list) foo-buffer-list)))
-
- (setq foo-buffer-list
- (append (list last) rest)))
- (switch-to-buffer (car foo-buffer-list)))
-
-
- --Jeff Abramson
- Microprocessor Division 6
- Intel Corporation, Hillsboro OR (503) 696-4784
- --
- Jeff Abramson
- Microprocessor Division 6
- Intel Corporation, Hillsboro OR (503) 696-4784
-