diff options
| author | Alan Mackenzie | 2023-04-14 16:37:33 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2023-04-14 16:37:33 +0000 |
| commit | dc842a71ed035dab1115f2e67d35dd07410e18be (patch) | |
| tree | 61d9c45eaa61e6e6efd10bf4fd7520aacf397c1d /doc/misc/cc-mode.texi | |
| parent | 7974a9349fc59a79b420f54cda9878792e69a239 (diff) | |
| download | emacs-dc842a71ed035dab1115f2e67d35dd07410e18be.tar.gz emacs-dc842a71ed035dab1115f2e67d35dd07410e18be.zip | |
Improve C++ concept indentation.
This fixes bug #62386.
* lisp/progmodes/cc-engine.el (c-forward-over-compound-identifier): Don't
move forward over whitespace following the identifier.
(c-forward-primary-expression): Add parameter stop-at-end meaning don't move
forward over whitespace after the construct when non-nil. Don't recognise a
primary expression when an open brace follows a parenthesized expression.
(c-forward-constraint-clause): Extracted from c-forward-c++-requires-clause.
Add parameter stop-at-end as above.
(c-forward-c++-requires-clause): New stop-at-end parameter as above. Call the
new function c-forward-constraint-clause.
(c-forward-concept-fragment, c-looking-at-concept)
(c-in-requires-or-at-end-of-clause, c-c++-vsemi-p): New functions.
(c-guess-basic-syntax): New CASE 5A.7: "defun" open in a requires expression.
CASE 5F: Close of a non-class declaration level block: Move to earlier in the
function.
CASE 5D: Also check for being in or at end of a constraint.
New CASE 20: A C++ requires sub-clause.
New CASE 16G: The closing brace of a requires clause.
New CASE 17J: First "statement" inside a requires "function".
(c-forward-primary-expression, c-forward-declarator, c-forward-decl-or-cast-1)
(c-looking-at-or-maybe-in-bracelist): Amend the method of detecting end of
symbol "requires" (aka c-fun-name-substitute-key).
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Amend the method
of detecting end of symbol "requires".
* lisp/progmodes/cc-langs.el (c-at-vsemi-p-fn): Change the C++ entry to
c-c++-vsemi-p.
(c-fun-name-substitute-key): Change to an unadorned regexp.
* lisp/progmodes/cc-vars.el (c-offsets-alist): Add new syntactic symbol
constraint-cont.
* doc/misc/cc-mode.texi (Syntactic Symbols): Add an entry for contraint-cont.
(Constraint Symbols): New node under Syntactic Symbols.
Diffstat (limited to 'doc/misc/cc-mode.texi')
| -rw-r--r-- | doc/misc/cc-mode.texi | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index 3a808619868..71bf3fcee4a 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi | |||
| @@ -330,6 +330,7 @@ Syntactic Symbols | |||
| 330 | * Multiline Macro Symbols:: | 330 | * Multiline Macro Symbols:: |
| 331 | * Objective-C Method Symbols:: | 331 | * Objective-C Method Symbols:: |
| 332 | * Java Symbols:: | 332 | * Java Symbols:: |
| 333 | * Constraint Symbols:: | ||
| 333 | * Statement Block Symbols:: | 334 | * Statement Block Symbols:: |
| 334 | * K&R Symbols:: | 335 | * K&R Symbols:: |
| 335 | 336 | ||
| @@ -4234,6 +4235,9 @@ The first line in a ``topmost'' definition. @ref{Function Symbols}. | |||
| 4234 | Topmost definition continuation lines. This is only used in the parts | 4235 | Topmost definition continuation lines. This is only used in the parts |
| 4235 | that aren't covered by other symbols such as @code{func-decl-cont} and | 4236 | that aren't covered by other symbols such as @code{func-decl-cont} and |
| 4236 | @code{knr-argdecl}. @ref{Function Symbols}. | 4237 | @code{knr-argdecl}. @ref{Function Symbols}. |
| 4238 | @item constraint-cont | ||
| 4239 | Continuation line of a topmost C++20 concept or requires clause. | ||
| 4240 | @ref{Constraint Symbols}. | ||
| 4237 | @item annotation-top-cont | 4241 | @item annotation-top-cont |
| 4238 | Topmost definition continuation lines where all previous items are | 4242 | Topmost definition continuation lines where all previous items are |
| 4239 | annotations. @ref{Java Symbols}. | 4243 | annotations. @ref{Java Symbols}. |
| @@ -4397,6 +4401,7 @@ Java. @ref{Java Symbols}. | |||
| 4397 | * Multiline Macro Symbols:: | 4401 | * Multiline Macro Symbols:: |
| 4398 | * Objective-C Method Symbols:: | 4402 | * Objective-C Method Symbols:: |
| 4399 | * Java Symbols:: | 4403 | * Java Symbols:: |
| 4404 | * Constraint Symbols:: | ||
| 4400 | * Statement Block Symbols:: | 4405 | * Statement Block Symbols:: |
| 4401 | * K&R Symbols:: | 4406 | * K&R Symbols:: |
| 4402 | @end menu | 4407 | @end menu |
| @@ -5071,6 +5076,39 @@ syntax due to it being a continuation of a variable declaration where preceding | |||
| 5071 | the declaration is an annotation. | 5076 | the declaration is an annotation. |
| 5072 | 5077 | ||
| 5073 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 5078 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 5079 | @node Constraint Symbols | ||
| 5080 | @subsection C++ Constraint Symbols | ||
| 5081 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| 5082 | |||
| 5083 | The C++20 standard introduced the notion of @dfn{concepts} and | ||
| 5084 | @dfn{requirements}, a typical instance of which looks something like | ||
| 5085 | this: | ||
| 5086 | |||
| 5087 | @example | ||
| 5088 | 1: template <typename T> | ||
| 5089 | 2: requires | ||
| 5090 | 3: requires (T t) @{ | ||
| 5091 | 4: @{ ++t; @} | ||
| 5092 | 5: @} | ||
| 5093 | 6: && std::is_integral<T> | ||
| 5094 | 7: int foo(); | ||
| 5095 | @end example | ||
| 5096 | |||
| 5097 | @ssindex constraint-cont | ||
| 5098 | Line 1 is assigned the familiar @code{topmost-intro}. Line 2 gets | ||
| 5099 | @code{topmost-intro-cont}, being the keyword which introduces a | ||
| 5100 | @dfn{requires clause}. Lines 3, 6, and 7 are assigned the syntax | ||
| 5101 | @code{constraint-cont}, being continuations of the requires clause | ||
| 5102 | started on line 2. Lines 4 and 5 get the syntaxes | ||
| 5103 | @code{defun-block-intro} and @code{defun-close}, being analyzed as | ||
| 5104 | though part of a function. | ||
| 5105 | |||
| 5106 | Note that the @code{requires} on Line 3 begins a @dfn{requires | ||
| 5107 | expression}, not a a requires clause, hence its components are not | ||
| 5108 | assigned @code{constraint-cont}. See | ||
| 5109 | @url{https://en.cppreference.com/w/cpp/language/requires}. | ||
| 5110 | |||
| 5111 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| 5074 | @node Statement Block Symbols | 5112 | @node Statement Block Symbols |
| 5075 | @subsection Statement Block Symbols | 5113 | @subsection Statement Block Symbols |
| 5076 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 5114 | @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |