[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC Mode and electric-pair "problem".

From: Alan Mackenzie
Subject: Re: CC Mode and electric-pair "problem".
Date: Sun, 1 Jul 2018 18:18:32 +0000
User-agent: Mutt/1.9.4 (2018-02-28)

Hello, Stefan.

On Sun, Jul 01, 2018 at 12:13:32 -0400, Stefan Monnier wrote:
> >> Why?    How 'bout:
> >>     char foo[] = "some unterminated // string
> > Bug compatibility with the current scan-sexps.

> I don't see why: currently, scan-sexps skips over the comment, but
> that's not a bug: it's exactly what it is documented to do.

There is no comment there, but scan-sexps skips to it nevertheless.  As
you know, I solved these anomalies some while ago with the comment-cache

> When you change the syntax property of ?\n to be "> s", it changes the
> behavior expected based on the documentation, ....

Er, documentation?  This new flag isn't documented yet, or at least not
in any permanent fashion.

> .... so in the above case it should treat the \n as closing the string
> rather than closing the comment.

I agree.

> It needs to work reliably for those languages where strings
> are indeed terminated by newline (e.g. jgraph-mode in GNU ELPA).

You mean, jgraph-mode is another use-case for `s'?  (I'm not familiar
with it.)

> > Hmmm.  Yes, this could increase the backward scanning time quite
> > substantially, but we already do this for back_comment, though.

> I expect the impact will be less than that of back_comment, but I think
> we'd want actual measurements anyway.


> > A possibility would be to apply the `s' flag only in a syntax-table
> > text property applied to the newlines of unterminated strings.

> But that brings us back to "why not use string-fence?".

Yes.  String-fence interferes with syntactical stuff "inside" the
invalid string, whereas the `s' flag won't.

> > I disagree.  Whilst editing code, it is in an invalid state nearly
> > all the time.

> But we usually don't make any effort to guess what the intended
> closest valid state might be, except where the user is actively
> editing the text (e.g. by proposing completion candidates for
> identifiers).

There's no need to guess.  The compiler defines the state, namely that
the (invalid) string ends at the EOL, and what follows is non-string.

> > I would hope you would weigh up the small additional complexity against
> > the new features it brings, and reach a balanced judgment, rather than
> > dismissing the new idea without consideration.

> I did consider it.  I just know syntax.c well enough that I'd be very
> surprised if the actual patch (as opposed to by guess at the what the
> patch would look like) makes me change my mind.

There's no need to guess.  back_maybe_comment is in the new
scratch/fontify-open-string branch.  It is NOT that complicated.

>         Stefan

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]