Skip to content

Instantly share code, notes, and snippets.

@randrews
Created May 19, 2021 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randrews/7f4cc7085214378fa4ef26b47fd44b3a to your computer and use it in GitHub Desktop.
Save randrews/7f4cc7085214378fa4ef26b47fd44b3a to your computer and use it in GitHub Desktop.
(defun kill-all-buffers ()
(interactive)
(mapcar (lambda (b)
;; Don't blow away scratch, for reasons, and also because doing so screws up
;; default-directory, setting it to the last thing we tab-completed (!?). This
;; causes annoyance when you try to set a path in the minibuffer later, making
;; it try to cd to that directory and then complaining that it's not there.
(if (not (string= (buffer-name b) "*scratch*"))
(kill-buffer b)))
(buffer-list))
(delete-other-windows))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment