Skip to content

Commit ea01e59

Browse files
author
Alan Mackenzie
committed
CC Mode: Don't indent a construct in a class after a template
This fixes bug#79438. * lisp/progmodes/cc-align.el (c-lineup-class-field-cont): New function. * lisp/progmodes/cc-vars.el (c-offsets-alist): Change the entry for class-field-cont from + to c-lineup-class-field-cont. * doc/misc/cc-mode.texi (Misc Line-Up): Add a new entry for c-lineup-class-field-cont.
1 parent 2cc5254 commit ea01e59

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

doc/misc/cc-mode.texi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6992,6 +6992,18 @@ the_larch, @hereFn{c-lineup-topmost-intro-cont}
69926992
@workswith @code{topmost-intro-cont}.
69936993
@end defun
69946994

6995+
@comment ------------------------------------------------------------
6996+
6997+
@defun c-lineup-class-field-cont
6998+
@findex lineup-class-field-cont (c-)
6999+
Indent continutation lines zero or one @code{c-basic-offset} steps.
7000+
This is intended for continuation lines within a class/struct
7001+
etc. construct. For a declaration following a template specification,
7002+
zero steps are used. Other constructs are indented one step.
7003+
7004+
@workswith @code{class-field-cont}.
7005+
@end defun
7006+
69957007
@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
69967008
@node Custom Line-Up
69977009
@section Custom Line-Up Functions

lisp/progmodes/cc-align.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ Works with: topmost-intro-cont."
9797
t))))
9898
c-basic-offset))))
9999

100+
(defun c-lineup-class-field-cont (langelem)
101+
"Line up continuation lines in a class zero or one indentation steps.
102+
For a declaration following a template specification, zero steps are
103+
used. Other constructs are indented one step."
104+
(save-excursion
105+
(beginning-of-line)
106+
(c-backward-syntactic-ws (c-langelem-pos langelem))
107+
(unless (eq (char-before) ?>)
108+
c-basic-offset)))
109+
100110
(defun c-lineup-gnu-DEFUN-intro-cont (langelem)
101111
"Line up the continuation lines of a DEFUN macro in the Emacs C source.
102112
These lines are indented `c-basic-offset' columns, usually from column 0.

lisp/progmodes/cc-vars.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ can always override the use of `c-default-style' by making calls to
13021302
;; Anchor pos: Boi at the func decl arglist open.
13031303
(member-init-cont . c-lineup-multi-inher)
13041304
;; Anchor pos: Beg of the first member init.
1305-
(class-field-cont . +)
1305+
(class-field-cont . c-lineup-class-field-cont)
13061306
;; Anchor pos: BOI of the line containing the class keyword.
13071307
;; 2nd pos: At the open brace.
13081308
(inher-intro . +)

0 commit comments

Comments
 (0)