One of the awesome things about Emacs is that in most coding buffers, TAB is not key to insert whitespace but instead to "do the right thing and go to the proper level of indent".
You can do this with a line, or an entire region.
However, if you're wanting to cleanup an entire buffer and have it indent to the right level, then selecting the whole thing and running a cleanup is just busy-work. Ideally we'd like to have a cleanup just default to cleaning up the whole buffer.
By using the crux-with-region-or-buffer command advice (middleware), we can do just that. If no region has been selected, then it just uses the entire buffer as the subject of indentation and untabification.
One of the awesome things about Emacs is that in most coding buffers,
TAB
is not key to insert whitespace but instead to "do the right thing and go to the proper level of indent".You can do this with a line, or an entire region.
However, if you're wanting to cleanup an entire buffer and have it indent to the right level, then selecting the whole thing and running a cleanup is just busy-work. Ideally we'd like to have a cleanup just default to cleaning up the whole buffer.
By using the
crux-with-region-or-buffer
command advice (middleware), we can do just that. If no region has been selected, then it just uses the entire buffer as the subject of indentation and untabification.