help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Killing Buffers


From: Andi Kleen
Subject: Re: Killing Buffers
Date: Sat, 03 Jan 2004 04:46:35 +0100
User-agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i586-suse-linux)

Brian Palmer <bpalmer@rescomp.Stanford.EDU> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]