emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Re: Algorithm in electric-pair--unbalanced-strings-p unsuita


From: Alan Mackenzie
Subject: Re: [PATCH] Re: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode
Date: Tue, 9 Jul 2019 16:00:22 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Stefan.

On Mon, Jul 08, 2019 at 16:59:31 -0400, Stefan Monnier wrote:
> >> > Don't knock it - it's working, and will give João what he wants whilst
> >> > preserving correct fontification.
> >> Several people have already pointed out that what you call here "correct
> >> fontification" is "incorrect" in the cases where the error is a missing
> >> \ rather than a missing ".
> > "Several people" is just one that I have seen, and he is wrong.

> João gave you actual examples where fontifying the second line as
> a code rather than string was an error.  So we're at least 2.

> > Whether the error "is" a missing \ or a missing " (for whatever
> > value of "is"), the purpose of the fontification is to draw
> > attention to this error.  This error is at the EOL where there is a
> > missing " or \.  In that sense CC Mode's fontification of it is
> > correct.

> Maybe we're not talking about the same thing:

We most assuredly are.  And you still haven't read my post from Date:
Thu, 4 Jul 2019 16:42:33 +0000, which dealt in full with your next three
paragraphs.  Please go and read that post now, and either assent to its
compelling logic or take issue with it in detail.

> The addition of some kind of error/warning face on this line is indeed
> always correct and is something that can easily be done without any
> need to fiddle with syntax-table text properties.  I'm definitely not
> arguing against this highlighting of the immediate error.

> But I'm talking about is the highlighting of the subsequent line(s).

> You seem to want them to be highlighted as if the next line was not part
> of a string (i.e. assume that a " was missing on the previous line),
> whereas all other major modes highlight that second line under the
> assumption that what was missing was a final \ on the previous line (or
> whatever other syntax the corresponding language requires).

> Both are wrong sometimes and right at other times.

Not really.  The overwhelmingly most common use case is typing in a
short string which fits on one line, when the next line is (almost)
always a line of code.  It is not sensible to fontify arbitrarily large
pieces of code as a string, just because the user hasn't yet reached her
closing double quote.

It is not up to the major mode to second guess the user.  It is the
major mode's job to indicate the presence and position of an error as
clearly as possible.  CC Mode's fontification does this.  Many other
modes don't.

[ .... ]

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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