home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / yic-buffer.el < prev    next >
Encoding:
Text File  |  1991-03-30  |  2.1 KB  |  75 lines

  1. ; Path: utkcs2!emory!swrinde!cs.utexas.edu!yale!cs.yale.edu!newsbase!choo
  2. ; >From: choo@cs.yale.edu (young-il choo)
  3. ; Newsgroups: comp.emacs
  4. ; Subject: Re: Editing multiple buffers and rotating between them
  5. ; Date: 7 Aug 90 23:39:19 GMT
  6. ; References: <236@jabberwock.shs.ohio-state.edu>
  7. ; Organization: Computer Science Yale University New Haven CT 06520-2158
  8. ; Nntp-Posting-Host: aqua.systemsx.cs.yale.edu
  9. ; > If I call emacs with, say, 5 file names:
  10. ; >     %emacs f1 f2 f3 f4 f5
  11. ; > ...
  12. ; > Rather, I'd like it to switch circularly through the whole list:
  13. ; > f5->f4->f3->f2->f1->f5->...
  14. ; > I wonder if this feature is not built in. 
  15. ; > Does someone know how to program it as key binding, e.g.
  16. ; > via key board macro definition?
  17. ; > Thanks in advance for any hints
  18. ; >  - Reiner
  19. ; Note:
  20. ; 'bury-buffer is the primitive that cycles through the buffers in one
  21. ;    direction (while ignoring insignificant buffers)
  22. ; 'yic-next-buffer is a simple function to cycle through the other way.  It
  23. ;    even displays buffers that are usually ignored, since I don't bother to
  24. ;    check them.
  25. ; 'yic-other-buffer changes to the default other buffer, without waiting for a
  26. ;    RET
  27. ; 'yic-kill-current-buffer kills current buffer.
  28. ; I use these all the time to move back and forth between buffers, and also the
  29. ; ability to kill buffers easily is great when I am in dired-mode.
  30. ; Hope this helps.
  31. ; --  Young-il Choo
  32. ;     Yale Computer Science  New Haven  CT 06520-2158
  33. ;     choo-young-il@yale.edu
  34. ; Put the following in your .emacs:
  35. (global-set-key "\C-x\C-p" 'bury-buffer)
  36. (global-set-key "\C-x\C-n" 'yic-next-buffer)
  37. (global-set-key "\C-x\C-o" 'yic-other-buffer)
  38. (global-set-key "\C-x\C-k" 'yic-kill-current-buffer)
  39.  
  40. (defun yic-next-buffer ()
  41.   "Switch to previous buffer in current window."
  42.   (interactive)
  43.   (switch-to-buffer (car (reverse (buffer-list)))))
  44.  
  45. (defun yic-other-buffer ()
  46.   "Switch to the other buffer (2nd in list-buffer) in current window."
  47.   (interactive)
  48.   (switch-to-buffer (other-buffer)))
  49.  
  50. (defun yic-kill-current-buffer ()
  51.   "Kill current buffer."
  52.   (interactive)
  53.   (kill-buffer (current-buffer)))
  54.  
  55. ;; end
  56.