emacs-devel
[Top][All Lists]
Advanced

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

Re: Fontifying unterminated strings [was: CC Mode and electric-pair "pro


From: Stefan Monnier
Subject: Re: Fontifying unterminated strings [was: CC Mode and electric-pair "problem".]
Date: Thu, 28 Jun 2018 19:56:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> I think the better option here is to focus on the following:
>> 1- Make sure the programmer is aware there's a problem in its code.
>>    I.e. highlight the opening quote or the non-escaped end-of-line or
>>    something in bright red or something like that.
>> 2- Don't try to guess what the user intended to do.
>>    Instead keep our code as simple as possible: the C code we're handed
>>    is broken, so there's no real clear "right behavior" anyway.
>
> How about the following suggestion - instead of having permanent
> string-fence syntax-table text properties to define the ends of
> unterminated strings:

My suggestion has no "string-fence syntax-table" or any such thing, so
I'm not sure what you're saying here.

Before suggesting something else, could you clarify the downside you see
with my proposal?

> (ii) we amend font-{lock,core}.el to apply the desired fontification, to
>   be like the new fontification in CC Mode?

This problem is not specific to C but it's not common to all programming
languages either, so I think that modifying font-(lock|core).el
for that would be a gross hack.

We could do it somewhat cleanly by having font-lock.el provide some
"standard" function that major modes could opt to use in their
font-lock-* settings, of course, but I'm having a hard time imagining
a solution with a nice semantics on that side: if we do it only by
tweaking faces, then we get inconsistent behavior between highlighting
and C-M-f, and if we do it by tweaking syntax-tables, then we get weird
differences between the case where font-lock is used and where it's not
used (e.g. between not-yet-displayed code and already displayed code, or
between the case where font-lock-mode is enabled or not).

`syntax-table` properties should be applied via
syntax-propertize-function in order to be reliably available.


        Stefan



reply via email to

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