home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / clean-buffers.el < prev    next >
Encoding:
Text File  |  1992-11-25  |  2.1 KB  |  62 lines

  1. ; Newsgroups: gnu.emacs.sources
  2. ; Path: hal.com!halaus!halaus!petonic
  3. ; From: petonic@hal.com (Michael A. Petonic)
  4. ; Subject: Deleting buffers in a regular manner
  5. ; Reply-To: petonic@hal.com (Michael A. Petonic)
  6. ; Organization: Henry's Laughing Gas Co., Inc.
  7. ; Date: 12 Nov 92 01:25:40 GMT
  8. ; Ever want to delete all those buffers whose names start with
  9. ; "sent \(mail\|reply\) to ..." and such?  Here's a snippet of my
  10. ; .emacs so that this may be done in a regular manner.  Just
  11. ; put the following in your .emacs and call M-x clean-buffers whenever
  12. ; your buffer list gets too big.  It works off of the clean-buffer-list
  13. ; variable which is a list of regular expressions to delete.  
  14. ; If called with an argument, clean-buffers will delete those buffers
  15. ; that are found with clean-buffer-extended-list, as well as what's
  16. ; in clean-buffer-list.
  17. ; -pet-
  18. ; -----------
  19. ;;;;;;;;;;;;;;;;;
  20. ;;
  21. ;; LCD Archive Entry:
  22. ;; clean-buffers|Michael A. Petonic|petonic@hal.com|
  23. ;; Buffer list cleanup stuff.|
  24. ;; 92-11-12||~/functions/clean-buffers.el.Z|
  25. ;;
  26. ;; -pet-  petonic@hal.com
  27. ;; Date: 92/11/11
  28. ;; 
  29. ;; Buffer list cleanup stuff.
  30. ;;
  31. ;; Standard GNU copyleft applies but I'm too harried to include it here.
  32. ;;  - not that anyone would "steal" this code, anyway.
  33. ;;
  34.  
  35. (defvar clean-buffer-list '("sent \\(reply\\)\\|\\(mail\\) to" "*gif parts*")
  36.   "List of regexs of buffers to clean up")
  37. (defvar clean-buffer-extended-list '("*Manual-")
  38.   "List of extended regexs of buffers to clean up when M-x clean buffers
  39. is called with an argument")
  40.  
  41. (defun clean-buffers (arg)
  42.   "Cleans temporary and old buffers as defined by the regexs in 
  43. clean-buffer-list.  If called with an ARG, then cleans up buffers specified
  44. by the regexs in clean-buffers-extended-list."
  45.   (interactive "P")
  46.   (mapcar '(lambda (buffer)
  47.          (let ((buffer (buffer-name buffer)))
  48.            (mapcar '(lambda (re)
  49.               (if (string-match re buffer)
  50.                   (progn
  51.                 (message "Deleting %s" buffer)
  52.                 (kill-buffer buffer))))
  53.                (append clean-buffer-list
  54.                    (if arg
  55.                    clean-buffer-extended-list
  56.                  nil)))))
  57.       (buffer-list)))
  58.