Subject: bug#63286: 30.0.50; CC Mode: New `c-for-clauses-as-arglist' style variable

From: Eli Zaretskii <[email-masked]>
Date: Fri, 05 May 2023 07:57:32 +0300

> From: Olivier Certner <[email-masked]>
> Date: Fri, 05 May 2023 00:22:12 +0200
> 
> This new style variable allows to disable special handling of "for"
> statements' clauses, which is that there are indented as statements,
> or continuations of such, when on separate lines instead of argument
> lists or continuations of such.

I don't think I understand the feature you are proposing.  Can you
elaborate, perhaps with examples?

> --- a/doc/misc/cc-mode.texi
> +++ b/doc/misc/cc-mode.texi
> @@ -2624,6 +2624,7 @@ Style Variables
>  Commas});@*
>  @code{c-cleanup-list} (@pxref{Clean-ups});@*
>  @code{c-basic-offset} (@pxref{Customizing Indentation});@*
> +@code{c-for-clauses-as-arglist} (@pxref{Syntactic Symbols});@*
>  @code{c-offsets-alist} (@pxref{c-offsets-alist});@*
>  @code{c-comment-only-line-offset} (@pxref{Comment Line-Up});@*
>  @code{c-special-indent-hook}, @code{c-label-minimum-indentation}
> @@ -4267,7 +4268,8 @@ Syntactic Symbols
>  Subsequent lines in an enum or static array list where the line begins
>  with an open brace.  @ref{Brace List Symbols}.
>  @item statement
> -A statement.  @ref{Function Symbols}.
> +A statement, including `for' clauses except if
> +@code{c-for-clauses-as-arglist} is true.  @ref{Function Symbols}.
>  @item statement-cont
>  A continuation of a statement.  @ref{Function Symbols}.
>  @item annotation-var-cont
> @@ -4309,15 +4311,22 @@ Syntactic Symbols
>  @item comment-intro
>  A line containing only a comment introduction.  @ref{Literal Symbols}.
>  @item arglist-intro
> -The first line in an argument list.  @ref{Paren List Symbols}.
> +The first line in an argument list or a parenthesized expression.
> +Note that @code{for} clauses are rather considered statements (or
> +their continuation) except if @code{c-for-clauses-as-arglist} is true.
> +@ref{Paren List Symbols}.
>  @item arglist-cont
>  Subsequent argument list lines when no arguments follow on the same
> -line as the arglist opening paren.  @ref{Paren List Symbols}.
> +line as the arglist opening paren.  Same remark concerning @code{for}
> +clauses as for @code{arglist-intro} above.  @ref{Paren List Symbols}.
>  @item arglist-cont-nonempty
>  Subsequent argument list lines when at least one argument follows on
> -the same line as the arglist opening paren.  @ref{Paren List Symbols}.
> +the same line as the arglist opening paren.  Same remark concerning
> +@code{for} clauses as for @code{arglist-intro} above.  @ref{Paren List
> +Symbols}.
>  @item arglist-close
> -The solo close paren of an argument list.  @ref{Paren List Symbols}.
> +The solo close paren of an argument list or a @code{for} clause.
> +@ref{Paren List Symbols}.
>  @item stream-op
>  Lines continuing a stream operator (C++ only).  @ref{Literal
>  Symbols}. @c @emph{FIXME!!!  Can this not be moved somewhere better?}

This uses @ref incorrectly.  The original text also uses it
incorrectly.  Alan, please fix that when you have time: those should
be @xref, not @ref.  The latter is not appropriate at the beginning of
a sentence.

> +(defcustom-c-stylevar c-for-clauses-as-arglist nil
> +  "Whether to consider for clauses as part of an argument list.

"for" should be quoted here, to make this sentence more clear.

> +The clauses of the for statement are normally considered by CC
> +mode as separate statements when at start of a line \(and
> +statement continuations when split).  Setting this variable to
> +non-nil indicates that they should be treated as any other
> +argument lists."

I don't understand what "argument lists" have to do with 'for'.  Or
maybe I don't understand what you mean by "for clauses".

> +  :type 'boolean
> +  :group 'c)

Defcustoms should have the :version tag.

Finally, would it be possible to have tests for this feature?

Thanks.