From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andi Kleen Newsgroups: gmane.emacs.help Subject: Re: Killing Buffers Date: Sat, 03 Jan 2004 04:46:35 +0100 Organization: unorganized Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <0whr7yim5pi.fsf@rescomp.Stanford.EDU> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1073102661 11977 80.91.224.253 (3 Jan 2004 04:04:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 3 Jan 2004 04:04:21 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 03 05:04:18 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Acd1O-0006T0-00 for ; Sat, 03 Jan 2004 05:04:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AcduM-0001NG-KL for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Jan 2004 00:01:06 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail Original-Newsgroups: gnu.emacs.help,gnu.emacs.sources Original-Lines: 33 Original-X-Trace: news.t-online.com 1073101602 02 20482 BWOLGr9LcEyHAL2 040103 03:46:42 Original-X-Complaints-To: usenet-abuse@t-online.de X-ID: ZBElVaZdgeIQ4tbl7uW-NTA-0dnvF4G7zFvYA3+IEnPQFNN6T-7H4e User-Agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i586-suse-linux) Cancel-Lock: sha1:Xu0qhKf2SAV1XE1VfATFWonQu4E= Original-Xref: shelby.stanford.edu gnu.emacs.help:119731 gnu.emacs.sources:9923 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15674 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15674 Brian Palmer writes: > Interesting; I doubt I'll use these, since I'm relatively content with > just C-x C-b and marking all the buffers to delete, but here are some I use this function. It is useful when you have multiple copies of a source tree around and you first edit some files in one copy and then switch to another copy and don't want C-x b to get you to files from the other again. It doesn't kill frames recently (mostly because I rarely use more than one), but I guess that would be an interesting extension too. ;;; FIXME should handle dired buffers too. (defun kill-buffer-tree (directory) "Kill all buffers that visit files below a specific directory tree." (interactive "DDirectory tree to kill from: ") (let* ((dir (expand-file-name directory)) (dir-re (apply 'concat "^" (if (string-match "/$" dir) (list dir) (list dir "/"))))) (mapcar '(lambda (buffer) (let ((file-name (buffer-file-name buffer))) (if (and file-name (string-match dir-re file-name) (y-or-n-p (concat "Kill buffer " file-name "? "))) (kill-buffer buffer)))) (buffer-list)))) -Andi