My java-mode in emacs wants to indent function arguments like this:
someLongFunctionName(
argumentNumberOne,
argumentNumberTwo,
argumentNumberThree,
argumentNumberFour
);
There are two problems here. Firstly, it wants to line up the start of the arguments with the end of the function name. Secondly, it wants to treat the the closet paren as if it were an argument, and thus lines it up with all other arguments. I don't like either of those behaviors.
I would much rather it indent my code like this:
someLongFunctionName(
argumentNumberOne,
argumentNumberTwo,
argumentNumberThree,
argumentNumberFour
);
c-mode does a much better job开发者_StackOverflow社区 of this by default, and I would like to carry over the behavior to java-mode if possible.
I still need to learn how the emacs indentation engine works, and at the moment I don't honestly really even know that much lisp. Those two learning exercises are definitely on my plate, but at the moment a quick copy-paste solution would be pretty awesome.
Try this
(defun my-indent-setup () (c-set-offset 'arglist-intro '+)) (add-hook 'java-mode-hook 'my-indent-setup)
From http://www.emacswiki.org/emacs/IndentingC
精彩评论