thefrontside / frontmacs

Package-based, web-centric, customizable, awesome-by-default, acceptance-tested Emacs distribution
MIT License
500 stars 22 forks source link

Clean up the entire buffer if no region is selected. #119

Closed cowboyd closed 6 years ago

cowboyd commented 6 years ago

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.

2018-03-09 11 30 59