[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: Mon, 18 Jun 2018 21:48:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> char *foo = "foo;
> int bar = 5;
> char *baz = "baz";
> The entire second line, and the third line, up to the first ", get string
> face.  We've been used to this for so long that we've lost sight of just
> how bad and amateurish it really is.

But what about when you write

    char *thedoc = "Here it is:
    - First do this
    - Then do that
    And that's it!";


Both cases are valid transient states.  Which one will occur more often
depends a lot on the particular kind of code you write and your
coding habits.

Emacs can't reliably distinguish the two cases, so whichever behavior it
chooses it will look "amateurish" in some cases.

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.

-- Stefan

reply via email to

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