diff options
| author | Alan Mackenzie | 2025-03-27 10:24:48 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2025-03-27 10:24:48 +0000 |
| commit | 555ec43a32ea8f3675c5a9d73ca30609eeaa9013 (patch) | |
| tree | 6ac83170f7d7ca750d96caeccedd18b88fdf456b /doc | |
| parent | 27c41d026f79ebc46fc8fe202836be0fd375bc1b (diff) | |
| download | emacs-555ec43a32ea8f3675c5a9d73ca30609eeaa9013.tar.gz emacs-555ec43a32ea8f3675c5a9d73ca30609eeaa9013.zip | |
C++ Mode: Fix some indentation bugs. FIxes bug#19867
1. Fix closing paren aligning with trailing comment on line
with matching open paren.
2. Fix indentation of first identifier inside a comma separated
list aligning with the type rather than the subsequent
identifiers.
3. Fix lambda expressions inside a brace list aligning like a
single statement.
* lisp/progmodes/cc-align.el (c-lineup-arglist): Take into
account any preceding comments when lining up the arguments in
the arglist.
(c-lineup-arglist-intro-after-paren): Handle comments properly,
and don't line up the closing parenthesis with a trailing
comment on the first line.
(c-lineup-item-after-paren-at-boi): Also allow a paren to count
as being at BOI when it is preceded only by open parens on that
line.
(c-lineup-runin-statements, c-lineup-ObjC-method-call): Hanle
comments better.
* lisp/progmodes/cc-engine.el (c-forward-comments) Introduce an
optional limit parameter. Use this limit in calls from
cc-align.el and cc-mode.el.
(c-just-after-func-arglist-p): Handle the presence of a
protection keyword such as "public".
(c-at-bracelist-p): Renamed from c-inside-bracelist-p, after
dropping the accept-in-paren parameter, having removed its
functionality.
(c-looking-at-statement-block-1): New function, based on the
old c-looking-at-statement-block. Enhanced to handle C++
lambda expressions, and to return the symbol `maybe' when the
contents of a brace delimited block fail to determine whether
it is a statement block.
(c-looking-at-statement-block): Enhanced to examine the context
of a brace delimited block when the contents are ambiguous.
(c-looking-at-c++-lambda-expression): Check the character after
point is a < before calling c-forward-<>-arglist.
(c-add-stmt-syntax): Make the context more accurate by calling
c-looking-at-statement-block.
(c-guess-basic-syntax, CASE 5D.5): Replace the syntactic symbol
topmost-intro-cont with the new symbol class-field-cont,
additionally determining the position of the enclosing brace as
an extra anchor point.
(c-guess-basic-syntax, CASE 5V): New case for an identifier
following a type inside class braces.
(c-guess-basic-syntax, CASE 9): Use
c-looking-at-statement-block to detect a brace list more
accurately.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context):
Rename the call to c-inside-bracelist-p to c-at-bracelist-p.
* lisp/progmodes/cc-langs.el (c-protection-kwds): Add an entry
for java-mode.
(c-stmt-block-only-keywords-regexp): Prevent this regexp also
matching a character preceding the keyword.
* /lisp/progmodes/cc-mode.el (c-before-change-include-<>)
(c-after-change-include-<>): Use the new limit argument to
c-forward-comments.
* lisp/progmodes/cc-styles.el (c-style-alist, "gnu" and "java"
styles): Change the offset for arglist-close to
c-lineup-arglist-close-under-paren.
* lisp/progmodes/cc-vars.el (c-offsets-alist): Introduce the
new syntactic symbol class-field-cont, giving it default
offset +.
* doc/misc/cc-mode.texi (Syntactic Symbols, Class Symbols):
Document the new syntactic symbol class-field-cont.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/cc-mode.texi | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index 566da9dad3d..4528ea42151 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi | |||
| @@ -4316,6 +4316,9 @@ annotations. @ref{Java Symbols}. | |||
| 4316 | First line in a member initialization list. @ref{Class Symbols}. | 4316 | First line in a member initialization list. @ref{Class Symbols}. |
| 4317 | @item member-init-cont | 4317 | @item member-init-cont |
| 4318 | Subsequent member initialization list lines. @ref{Class Symbols}. | 4318 | Subsequent member initialization list lines. @ref{Class Symbols}. |
| 4319 | @item class-field-cont | ||
| 4320 | Lines continuing the first line inside a class/struct etc. definition. | ||
| 4321 | @ref{Class Symbols}. | ||
| 4319 | @item inher-intro | 4322 | @item inher-intro |
| 4320 | First line of a multiple inheritance list. @ref{Class Symbols}. | 4323 | First line of a multiple inheritance list. @ref{Class Symbols}. |
| 4321 | @item inher-cont | 4324 | @item inher-cont |
| @@ -4669,6 +4672,25 @@ elements: | |||
| 4669 | The @code{friend} and @code{inline-open} syntactic symbols are | 4672 | The @code{friend} and @code{inline-open} syntactic symbols are |
| 4670 | modifiers that do not have anchor positions. | 4673 | modifiers that do not have anchor positions. |
| 4671 | 4674 | ||
| 4675 | @ssindex class-field-cont | ||
| 4676 | In the following example, line 1 gets the syntax @code{topmost-intro}, | ||
| 4677 | and line 2 @code{((inclass 1) (topmost-intro 1))} as expected. Lines | ||
| 4678 | 3, 4, and 5 are given the syntax @code{(class-field-cont 18 12)} | ||
| 4679 | rather than @code{topmost-intro-cont}. This makes it easier to indent | ||
| 4680 | several comma separated fields with respect to their defining type, | ||
| 4681 | when @code{topmost-intro-cont} would tend to leave elements directly | ||
| 4682 | underneath their type. @xref{Function Symbols}. The anchor points are | ||
| 4683 | the positions of the type and the enclosing class's brace. | ||
| 4684 | |||
| 4685 | @example | ||
| 4686 | 1. struct foo @{ | ||
| 4687 | 2. long | ||
| 4688 | 3. a, | ||
| 4689 | 4. b, | ||
| 4690 | 5. c; | ||
| 4691 | 6. @}; | ||
| 4692 | @end example | ||
| 4693 | |||
| 4672 | @ssindex template-args-cont | 4694 | @ssindex template-args-cont |
| 4673 | Template definitions introduce yet another syntactic symbol: | 4695 | Template definitions introduce yet another syntactic symbol: |
| 4674 | 4696 | ||