3

I use Emacs for Android development and this has been bugging me lately.

I'm trying to get the following indentation behaviour:

submitBtn.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    submitEnquiry();
  }
});

and with my current setup I'm getting this:

submitBtn.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      submitEnquiry();
    }
  });

Quite a specific case I know, but one that I'm running into very often. I'm using Emacs 24.4 and I'm only modifying c-basic-offset in my java-mode-hook at the moment.

4

After some poking around, it looks like this has fixed it (getting called in java-mode-hook):

(c-set-offset 'inexpr-class 0)

By default it is set to +. inexpr-class controls the indentation level for anonymous classes and anonymous initialisation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.