3

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 indentation space in a anonymous class ?

Thanks.

1 Answer 1

3

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/[email protected]/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))))
Sign up to request clarification or add additional context in comments.

1 Comment

Yes exactly. I try with c-basic-offset to 3, and the line is indented twice (6 spaces). How can I fix the bug ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.