I write a C99 program and often use complex literals. However, Emacs does not seem to back down properly.
For example, here is a simple function with manual indentation:
SDL_Point random_point_within_rect(SDL_Rect r) { return (SDL_Point) { .x = (rx + (rand() % rw)), .y = (ry + (rand() % rh)), }; }
And this is how it looks when I use Mx indent-region
:
SDL_Point random_point_within_rect(SDL_Rect r) { return (SDL_Point) { .x = (rx + (rand() % rw)), .y = (ry + (rand() % rh)), }; }
My hypothesis is that Emacs does not recognize curly braces in (type) { ... }
as the same things as type x = { ... }
, since it that has exactly the same content in curly brackets, works fine:
SDL_Point random_point_within_rect(SDL_Rect r) { SDL_Point p = { .x = (rx + (rand() % rw)), .y = (ry + (rand() % rh)), }; return p; }
Is there a way to get Emacs to process complex literals, such as string literals, or some other way to fix the indent here?
Thanks.
source share