Bind "q" to a DWIM kill command
Bind "q" to a DWIM kill command

If 0 or 1 non-special buffers are open, "q" (in dired-mode and view-mode maps)
will kill emacs.

But if more than 1 non-special buffers are open, "q" will only kill the current
buffer.

This is useful when you do "eless ." then open one of the files, and then mean
to hit "q" to go back to the dired buffer.

Repeated hitting of "q" will decrease the count of non-special buffers and
eventually quit eless.

Non-special buffers are the ones whose names do not begin with a space or *.. so
buffers like "*scratch*", "*Messages*", minibuffers, etc are not counted in this
non-special group.

Typical usage scenario:

- eless foo.txt -> q quits eless
- eless foo.txt -> C-x C-f bar.txt -> q kills the bar.txt buffer -> q, now, quits eless
- eless . -> RET to open a file -> q kills that opened file buffer -> q, now, quits eless

kaushalmodi/eless