Because I'm always needing this between tasks...
;; kill buffers visiting /scratch or /tmp files
(defun cleanup ()
(interactive)
(let* (
(n)
(list)
(file)
)
(setq list (buffer-list))
(setq n 0)
(save-excursion
(dolist (elt list)
(setq file (buffer-file-name (get-buffer elt)))
(if (and
file
(or
(string-match "^/scratch/" file)
(string-match "^/tmp/" file)
)
)
(progn
(if (kill-buffer elt)
(setq n (+ n 1))
)
)
)
)
(message "Delete %d buffer%s." n (if (= n 1) "" "s"))
)
)
)
No comments:
Post a Comment