c-offsets-alist, hanging braces
With emacs and jdee, out of the box formatting for inline, anonymous classes in java have bad hanging braces. Here’s an example:
public class Xyz { public void doX() { Predicate p = new Predicate() { public boolean evaluate(Object input) { } }; //this line is badly indented }}
In order to fix this, I started looking at c-offsets-alist. Discovered that most of the defaults weren’t working for me, since this block has two styles inexpr-class, and class-close. I came up with this:
(c-set-offset 'inexpr-class (lambda (syntax) (if (eq syntax 'class-close) '- 0)))
That seems to fix the problem, not entirely sure that it is correct, The correct indenation looks like:
public class Xyz { public void doX() { Predicate p = new Predicate() { public boolean evaluate(Object input) { } }; }}
About this entry
You’re currently reading “c-offsets-alist, hanging braces,” an entry on Evadnoob
- Published:
- April 22, 2007 / 1:09 pm
- Category:
- emacs
- Tags:
No comments yet
Jump to comment form | comments rss [?] | trackback uri [?]