unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Gulshan Singh <gsingh2011@gmail.com>
Cc: acm@muc.de, Lars Ingebrigtsen <larsi@gnus.org>, 21409@debbugs.gnu.org
Subject: bug#21409: 24.5; Wrong syntactic information for two line statement in an arglist
Date: Sat, 12 Mar 2022 11:32:50 +0000	[thread overview]
Message-ID: <YiyE4jK9zIVMK/SX__30040.7913791545$1647084827$gmane$org@ACM> (raw)
In-Reply-To: <CANEZYrf-W1Wei0PQrFb9BzXt9s7uQBzKNX1zXtOiKPDQuOL0OA@mail.gmail.com>

Hello, Gulshan.

Sorry I missed your bug report back in 2015.

On Fri, Mar 11, 2022 at 17:52:38 -0800, Gulshan Singh wrote:
> I know this is an old bug report, but I just realized it got a response,
> and it seems like the behavior hasn't changed.

Also, a big thank you for cutting the C fragment down to an easy to work
with minimum.

> On Thu, Dec 3, 2020 at 3:07 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:

> > Gulshan Singh <gsingh2011@gmail.com> writes:

> > > In c-mode (and all derivatives), the following code has the wrong
> > > syntactic information (at least, in my opinion):

> > > foo(bar
> > >     .baz()
> > >     .qux());

> > > Putting point at `.baz()` and pressing C-c C-s shows it as an
> > > `arglist-cont-nonempty`, when I'd expect it to be a
> > > `statement-cont`.

I'm afraid I can't agree with you here.  The bar.baz().qux() is an
expression, not a statement, as it is lacking the terminating ; which
would make it a statement.  I think the arglist-cont-nonempty is correct.
It is more specific than statement-cont, which could only have the start
of foo as its anchor position.

> > > This causes the code to have the wrong indentation, as above I
> > > would like to have the continued statements to be indented one
> > > c-basic-offset, not aligned to the opening brace.

I think the best solution to the problem would be to write a new Line-Up
function for this particular scenario, and to make it available to users
to insert into the c-offsets-alist entry for arglist-cont-nonempty.  The
page "Customizing Indentation" in the CC Mode manual is pertinent here.

But first, we need to firm up the specification.  What, precisely, will
trigger this new Line-Up function?

What about the struct members not being functions:

    foo(bar
          .baz
	  .qux);

?  What about the . operator being at the end of the previous line:

    foo(bar.
          baz().
	  qux());

?  What is the primary construct which should trigger the new Line-Up
function?  Am I right in thinking it's the . operator combined with line
breaks, and nothing else?  What about, for example, the ? : operators:

    foo(bar
          ? baz()
	  : qux());

?  This is getting kind of complicated.  ;-)  Sorry.

> > (This bug report unfortunately got no response at the time.)

> > I'm not sure how that should be indented, really -- the current
> > indentation looks reasonable to me, I think?


> It's definitely reasonable, but it's not what I'd prefer, which would be
> this:

> foo(bar
>       .baz()
>       .qux());

> `.baz()` and `.qux()` are indented two spaces (my value for
> `c-basic-offset`) from the start of `bar`, as opposed to aligned with
> `bar`. This matches what happens if the call to `foo` isn't there:

> bar
>   .baz()
>   .qux();

> In any case, regardless of what indentation one would prefer for this case,
> the issue remains that `c-show-syntactic-information` should be showing
> `statement-cont` instead of `arglist-cont-nonempty` at `.baz()`.

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2022-03-12 11:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04  5:50 bug#21409: 24.5; Wrong syntactic information for two line statement in an arglist Gulshan Singh
2020-12-03 11:07 ` Lars Ingebrigtsen
2022-03-12  1:52   ` Gulshan Singh
2022-03-12 11:32     ` Alan Mackenzie [this message]
     [not found]     ` <YiyE4jK9zIVMK/SX@ACM>
2022-03-13 13:43       ` Alan Mackenzie
2022-04-09 21:43         ` Gulshan Singh
2022-04-23 14:23           ` Alan Mackenzie
2022-04-23 20:10           ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='YiyE4jK9zIVMK/SX__30040.7913791545$1647084827$gmane$org@ACM' \
    --to=acm@muc.de \
    --cc=21409@debbugs.gnu.org \
    --cc=gsingh2011@gmail.com \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).