Skip to content

Instantly share code, notes, and snippets.

@erkyrath
Last active August 29, 2015 14:03
Show Gist options
  • Save erkyrath/90ae298f1cd6add8cc0e to your computer and use it in GitHub Desktop.
Save erkyrath/90ae298f1cd6add8cc0e to your computer and use it in GitHub Desktop.
(defun my-filter (condp lst)
(delq nil
(mapcar (lambda (x) (and (funcall condp x) x)) lst)))
(defun too-many-buffers-query ()
(let* ((ls (my-filter (lambda (buf) (buffer-file-name buf)) (buffer-list)))
(count (length ls)))
(if (> count 8)
(y-or-n-p (format "%d file buffers exist: really quit? " count))
t))
)
(add-hook 'kill-emacs-query-functions 'too-many-buffers-query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment