Closed rheaplex closed 4 years ago
Hey @robmyers thank you for the bug report and apologies for the late response!
So I tried to reproduce what you are saying with the following program:
contract foo {
struct boo {
uint256 a;
}
function funA() {
return;
}
}
But the indentation does not appear like in your screenshot. How did you automatically ident? By pressing TAB?
My c/c++ code setup which also applies in solidity is here: https://github.com/LefterisJP/.emacs/blob/90d542d8ee0ddc68a58fd1e2318b694a3dd7d5f5/lk/cstyle-setup.el#L18-L79
Thank you for looking at this.
The embarrassing outcome of a long process of discovery is that this is an issue with emacs 27 in git. I reverted to emacs 26 and everything is fine.
My apologies for not catching that before asking.
@rheaplex , I am running into this issue with bleeding-edge emacs 28. Do you recall what the causative issue was in emacs27?
It can still be reproduced on Emacs29. Adding a semicolon after struct and enum can correct indentation, but it cannot be compiled.
Thank you for solidity-mode!
When using it to automatically indent code, the indentation of lines after the closing curly brace of a struct is increased by one level until after closing another declaration:
c-mode seems to be expecting a semicolon after the closing curly brace of the struct, but Solidity doesn't require one (and complains if one is provided, although doing so fixed the indentation).
I'm not quite sure how to address this, modifying c-offsets-alist for class-close (the syntactic type returned by C-c C-s) affects the indentation of the curly brace, not the lines that follow it.
I addressed similar issues with my desired indentation for events and other constructs with closing parentheses on a new line using: