[Top][All Lists]

[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: Sat, 30 Jun 2018 23:50:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> The initial problem I tried to solve was for CC Mode source files with
> things like:
>     char foo[] = "foo
>     char bar[] = "bar";
> Historically, the missing " on "foo has caused subsequent lines to have
> their string quoting reversed.  This is not good.

Of course, as mentioned elsewhere, the new functionality is not good
either when you have

    char foo[] = "first line
    second line\
    third line";

Unless we find a magic way to distinguish those cases, both behaviors
will be sometimes right and sometimes wrong (and of course, neither
really matters since the code is invalid and will be inevitably fixed
soon by the user).

> A recent series of CC Mode commits "solved" this by putting string-fence
> syntax-table text properties on the " and the NL around foo.  This caused
> a "make check" test to fail.  With electric-pair-mode enabled and
> electric-pair-skip-whitespace set to 'chomp, in the following:

Complexity brings bugs, indeed.

> Also, the CC Mode solution has the disadvantage that other languages
> cannot get the same fontification advantages, namely that the "foo gets
> warning-face on the ", and string face extends ONLY to EOL.

    "foo gets warning-face on the "

is completely unrelated to the discussion at hand: you can have it both
with the new code and the old code, and indeed CC-mode had it with the
old code as well.

> What I'm now proposing, and implementing as a trial, is to enhance the
> syntax table facilities to support unterminated strings.

Oh indeed, complexity calls for yet more complexity.

> Stefan is concerned that the extra functionality may not justify the
> increase in complexity in syntax.c.



reply via email to

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