emacs-devel
[Top][All Lists]
Advanced

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

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


From: Stefan Monnier
Subject: Re: CC Mode and electric-pair "problem".
Date: Sun, 01 Jul 2018 12:13:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> 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.

When you change the syntax property of ?\n to be "> s", it changes the
behavior expected based on the documentation, so in the above case it
should treat the \n as closing the string rather than closing
the comment.

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

> 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?".

> 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).

>> I can't imagine how seeing the code could change my opinion on whether
>> it's worth it.
> 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.


        Stefan




reply via email to

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