-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if (constraint) misindents the following block (which is the function/struct/etc. body) #127
Comments
Strange, I don't get that side effect if I apply the suggested workaround. |
This Emacs-D-Mode test passes for me on Emacs 29.1: // #run: (progn (c-set-offset 'substatement-open 0) (c-set-offset 'knr-argdecl-intro 0) (d-test-indent))
void foo()()
{
bar();
}
void foo()()
if (true)
{
bar();
}
void foo()()
if (true) {
bar();
} (Save as |
I've never be able not to, but maybe I have some other offsets that are causing it. I'll look into it further when I get a chance. |
Is that with Maybe it could be one of the other offset settings that Emacs-D-Mode sets for indentation tests? Lines 89 to 150 in a4f9026
|
Yes. And FWIW, GNU Emacs 29.4 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2024-06-23 Out of time for now, gotta go. |
A type constraint on a generic function, struct, etc. apparently looks to emacs like an if statement within the "knr area" (the region between the function signature and the opening brace, which in K&R C consisted of parameter declarations) and so it thinks the function body is a block belonging to the if statement, and indents it as such.
Workaround:
(c-set-offset 'knr-argdecl-intro 0)
and putting the constraint on a separate line and the opening brace of the function on the same line minimizes the damage, but the function's closing brace is indented by 1 space. e.g.,With the opening brace on a separate line, the whole function is indented 1 space:
(Apparently none of the phobos maintainers use emacs, because the library is chock full of constraints and this bug has apparently always be present in d-mode.el)
The text was updated successfully, but these errors were encountered: