Discussion:
lineup under braces?
(too old to reply)
a***@gmail.com
2012-12-18 02:20:39 UTC
Permalink
When in c-mode, I'd like 'brace containing constructs' to line up this way:


int foo[] = {
<-c-basic-offset->value1,
<-c-basic-offset->value2,
<-c-basic-offset->value3,
};


I know I need to set 'brace-list-open/close/intro/entry', but it doesn't look like there's an existing function which can handle the above requirements. The closest I can find is: c-lineup-arg-list-close-under-paren, which doesn't quite work.

I'm new to emacs, so any help would be greatly appreciated.

Thanks,
Andrew
a***@debesys.net
2012-12-18 16:34:04 UTC
Permalink
Post by a***@gmail.com
int foo[] = {
<-c-basic-offset->value1,
<-c-basic-offset->value2,
<-c-basic-offset->value3,
};
I know I need to set 'brace-list-open/close/intro/entry', but it doesn't look like there's an existing function which can handle the above requirements. The closest I can find is: c-lineup-arg-list-close-under-paren, which doesn't quite work.
I'm new to emacs, so any help would be greatly appreciated.
Thanks,
Andrew
I found a solution that works. Seems to work as I described above.

(defun styles-indent-lineup-under-block (langelem)
(save-excursion
(beginning-of-line)
(backward-up-list)
(vector (+ tab-width (current-column)))
)
)

(defun styles-lineup-under-block (langelem)
(save-excursion
(beginning-of-line)
(backward-up-list)
(vector (current-column))
)
)

Loading...