Emacs fix the indentation of the java-mode
Suppose that code :
Command provisionHostCommand = new Command() {
@Override
public void execute() {
final List<Host> hosts = new ArrayList<Host>(display.getSelectionModel().getSelectedSet());
eventBus.fireEvent(new ProvisioningHostEvent(hosts));
}
};
Take a look about the indention. There's 4 spaces for the Command anonymous class. I have my c-basic-offset set to 2. How can I reduce the indentat开发者_StackOverflow中文版ion space in a anonymous class ?
Thanks.
Well, this seems to work for me:
(c-set-offset 'inexpr-class 0)
I'm not quite sure why, though, I've looked at the documentation and it seems to suggest that anonymous classes should only be indented by c-basic-offset
. Perhaps they're indented twice because of the opening curly brace?
Edit: How about this workaround from http://www.mail-archive.com/jde@sunsite.auc.dk/msg01159.html?
(add-hook 'c-mode-common-hook
'(lambda ()
(c-set-offset 'substatement-open 0)
(if (assoc 'inexpr-class c-offsets-alist)
(c-set-offset 'inexpr-class 0))))
精彩评论