Here is a Semantic lexer based indent
region function for formatting code in Emacs. It should work for Java and
_javascript_. Feel free to use it if you like the output or customize it
to suit your needs.
Code: semantic-indent-region
Features
- Removes redundant whitespace. Multiple new lines are replaced by two new lines to mark paragraph separation.
- Uses tab for indent and fill-column width to wrap lines (hard wrap). Set values for tab-width and fill-column as per your preference.
- Adds one indent for each level of nested code.
- Splits line on semi-colon.
Regards,
Anand