Many text editors and IDEs offer the ability to close all open files with the exception of the one you’re currently in. Emacs does not. At least it doesn’t until you add a snippet such as this one to your Emacs setup:
1 2 3 4 5 6 7
Note that the command takes care not to kill special buffers(buffers that do not correspond to files).
I’d suggest binding
The command can be implemented in a more elegant manner if one chooses to
leverage either the built-in
cl.el library or the newer
dash.el. Here’s the version of
the same command from Prelude,
1 2 3 4 5 6 7 8 9 10 11
According to your personal preference on functional programming the second version might seem either much more elegant, ghastly or just the same of the original.