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

Previous Next

Package: emacs;

Reported by: Olivier Certner <ocert.dev <at> free.fr>

Date: Thu, 4 May 2023 22:20:02 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 63286 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Olivier Certner <ocert.dev <at> free.fr>, Alan Mackenzie <acm <at> muc.de>
Cc: 63286 <at> debbugs.gnu.org
Subject: Re: bug#63286: 30.0.50;
 CC Mode: New `c-for-clauses-as-arglist' style variable
Date: Fri, 05 May 2023 07:57:32 +0300
> From: Olivier Certner <ocert.dev <at> free.fr>
> 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.




This bug report was last modified 1 year and 257 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.