Created
June 10, 2010 04:38
-
-
Save satyr/432559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun buffer-directory (&optional buf (selected-buffer)) | |
(let ((name (get-buffer-file-name buf))) | |
(and name (directory-namestring name)))) | |
(defun close-buffers-within (&optional (dir (buffer-directory))) | |
(interactive) | |
(when dir | |
(let ((re (concat "^" (regexp-quote dir))) | |
(closed '())) | |
(dolist (buf (buffer-list)) | |
(when (string-match re (or (buffer-directory buf) "")) | |
(push (buffer-name buf) closed) | |
(delete-buffer buf))) | |
(message "~A: ~{~A ~}" (length closed) closed)))) | |
(global-set-key '(#\C-c #\w) 'close-buffers-within) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment