AutoFormat.java, Mk III

This is a finished copy of what was #2560.