home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / auto-buffmen.el < prev    next >
Encoding:
Text File  |  1990-03-21  |  1.9 KB  |  51 lines

  1. ;Article 517 of gnu.emacs
  2. ;Path: ark1!uakari.primate.wisc.edu!uwm.edu!wuarchive!wugate!uunet!xyzzy!tiktok!meissner
  3. ;From: meissner@tiktok.dg.com (Michael Meissner)
  4. ;Newsgroups: gnu.emacs
  5. ;Subject: Re: emacs file1 file2 ---> initiates emacs with multiple buffers.
  6. ;Message-ID: <1668@xyzzy.UUCP>
  7. ;Date: 8 Oct 89 18:41:30 GMT
  8. ;References: <22598@sequent.UUCP>
  9. ;Sender: usenet@xyzzy.UUCP
  10. ;Reply-To: meissner@tiktok.UUCP (Michael Meissner)
  11. ;Distribution: gnu
  12. ;Organization: Data General (Languages @ Research Triangle Park, NC.)
  13. ;Lines: 34
  14. ;Keywords: Multiple buffers,
  15. ;
  16. ;In article <22598@sequent.UUCP> paulr@sequent.UUCP (Paul Reger) writes:
  17. ;| Awhile back I posted to this group asking if I initiated emacs with
  18. ;| multiple file arguments:
  19. ;| 
  20. ;| emacs file1 file2 ... filen
  21. ;| 
  22. ;| How would I go about making emacs come up with 2 buffers or maybe just
  23. ;| the *Buffer List* menu.  ...
  24. ;
  25. ;However the auto-buffer-menu code as posted does contain an assumption
  26. ;about how many buffers emacs starts with.  I tend to do things like
  27. ;create a *server* buffer in my .emacs file when I automatically start
  28. ;the server.  Also, the assumption might break when emacs version 19
  29. ;comes out.  Here is a revised auto-buffer-menu, that actually checks
  30. ;whether the buffers listed are connected to files (with the elisp
  31. ;buffer-file-name function):
  32.  
  33. (defun auto-buffer-menu ()
  34.   (let ((count 0) buffer (buf-list (buffer-list)))
  35.     (while buf-list
  36.       (setq buffer (car buf-list))
  37.       (setq buf-list (cdr buf-list))
  38.       (if (buffer-file-name buffer)
  39.       (setq count (+ count 1))))
  40.     (cond ((> count 2)
  41.        (buffer-menu t)
  42.        (delete-other-windows))
  43.       ((= count 2)
  44.        (pop-to-buffer nil)))))
  45.  
  46. ;--
  47. ;Michael Meissner, Data General.
  48. ;Uucp:        ...!mcnc!rti!xyzzy!meissner        If compiles were much
  49. ;Internet:    meissner@dg-rtp.DG.COM            faster, when would we
  50. ;Old Internet:    meissner%dg-rtp.DG.COM@relay.cs.net    have time for netnews?
  51.