home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / buff-mark.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  3.2 KB  |  87 lines

  1. ;From: ecb@utrccm (ecb)
  2. ;Newsgroups: comp.emacs
  3. ;Subject: Buffer-menu kill all files (SOLUTION)
  4. ;Message-ID: <8908161549.AA01367@utrccm.SMC.UTC.COM>
  5. ;Date: 16 Aug 89 15:49:28 GMT
  6. ;References: <679@megatek.UUCP>
  7. ;Organization: BBN news/mail gateway
  8. ;Lines: 77
  9. ;
  10. ;
  11. ;on 9 Aug 89 15:07:44 GMT,
  12. ;Dion Hollenbeck <hp-sdd!megatek!eta!hollen@hplabs.hp.COM> said:
  13. ;    Dion> Sender: arpa-unix-emacs-request@bbn.COM References:
  14. ;    Dion> <661@mipos3.intel.com> Source-Info: From (or Sender) name
  15. ;    Dion> not authenticated.
  16. ;
  17. ;    Dion> Thanks to all who responded to my question.  With help from
  18. ;    Dion> them and some more poking around myself, the solution is as
  19. ;    Dion> follows for anyone who could benefit by it.  The reason I
  20. ;    Dion> needed this code is that I have been using tags-search and
  21. ;    Dion> after a search I sometimes end up with up to 60 or so files
  22. ;    Dion> being edited by Emacs.  This is a quick way to kill all of
  23. ;    Dion> them.  When the function finishes, the point is at the
  24. ;    Dion> bottom of the buffer list window and I can merely move up
  25. ;    Dion> the the first file I want to keep, use "u" on all my regular
  26. ;    Dion> files to be kept and then "x" to delete all the ones used in
  27. ;    Dion> tags-search.
  28. ;
  29. ;Good idea. I've had this problem myself. 
  30. ;
  31. ;I've added an inverse of the function you posted (for when fat fingers
  32. ;or brain-dead key-banging might cause me grief) and offer it here.
  33. ;
  34. ;Also I prefer not to have modified buffers be marked for deletion by
  35. ;any automatic process (too much chance that I'll purge useful changes)
  36. ;so I've modified the original code to check and leave such buffers
  37. ;alone.  A better solution would be to mark, in some easily recognized
  38. ;way, all buffers added by a tags search, but this is beyond my skills.
  39. ;Anyone else care to try?
  40. ;
  41. ;            Bud Boman
  42. ;            United Technologies Research Center
  43. ;            (203) 727-7128
  44. ;            ecb@utrccm.smc.utc.com
  45. ;
  46.  
  47. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  48. ;;  Add key to buffer menu mode
  49. (defun buffer-menu-mode-hook-fun ()
  50.     "Add key mapping for Buffer-menu-mark-all-delete function"
  51.   (define-key Buffer-menu-mode-map "a" 'Buffer-menu-mark-all-delete)
  52.   (define-key Buffer-menu-mode-map "U" 'Buffer-menu-unmark-all-delete)
  53.   (use-local-map Buffer-menu-mode-map)
  54. )
  55.  
  56. ;;  Add function name to mode hook
  57. (setq buffer-menu-mode-hook 'buffer-menu-mode-hook-fun)
  58.  
  59. ;;  Define additional function for buffer menu mode
  60. (defun Buffer-menu-mark-all-delete ()
  61.   "Mark all buffers to be deleted by \\[Buffer-menu-execute] command.
  62.     Finish at the end of the buffer menu."
  63.   (interactive)
  64.   (goto-char (point-min))
  65.   (while (looking-at " [-M]") (forward-line 1))
  66.   (while (looking-at "[ .D]")
  67.     (if (or (looking-at " \\*") (looking-at ".\\*") )
  68.         (forward-line 1) (Buffer-menu-delete)
  69.         )
  70.     )
  71.   (goto-char (point-min) )
  72.   (next-line 2)
  73. )
  74.  
  75. (defun Buffer-menu-unmark-all-delete ()
  76.   "Mark all buffers to be deleted by \\[Buffer-menu-execute] command.
  77.     Finish at the end of the buffer menu."
  78.   (interactive)
  79.   (goto-char (point-min))
  80.   (while (or (looking-at " [-M]") (looking-at "\\.") ) (forward-line 1))
  81.   (while (looking-at "[ D]") 
  82.     (Buffer-menu-unmark)
  83.   )
  84.   (goto-char (point-min) )
  85.   (next-line 2)
  86. )
  87.