all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-pretest-bug@gnu.org, Chong Yidong <cyd@stupidchicken.com>,
	3269@emacsbugs.donarmstrong.com,
	Thomas Christensen <thomasc@thomaschristensen.org>,
	emacs-devel@gnu.org
Subject: bug#3269: 23.0.93; C-mode text highlighting
Date: Tue, 19 May 2009 10:26:19 +0000	[thread overview]
Message-ID: <20090519102619.GA1317__3611.90801854736$1242730357$gmane$org@muc.de> (raw)
In-Reply-To: <jwvk54d262g.fsf-monnier+emacsbugreports@gnu.org>

Hi, Stefan,

On Mon, May 18, 2009 at 10:24:02PM -0400, Stefan Monnier wrote:
> > The opening string quote (?\" or ?\') gets f-l-warning-face.  The
> > rest of the unclosed string (up to the first EOL which isn't escaped)
> > gets f-l-string-face.

> > Actually, that's not _quite_ "proper".  A string with an even number of
> > backslashes at an EOL is broken at that point, but the font locking
> > doesn't show this (yet).  I don't suppose that will bother you all that
> > much.  ;-)

Whoops!  I was utterly wrong there.  When a string inside a #define has
an even number of backslashes at an EOL, this is perfectly legal; the
last \ escapes the EOL, concatenating the lines, and the second last \
escapes the first character on the next line.  Nice simple language, C.
;-)

> I won't oppose the change, but just to be clear: I think that the
> increased code complexity introduced by your patch is a worse problem
> than the "improper" highlighting it tries to fix.

Well, I don't agree with that, but I'm beginning to think that the
current fontification (ommitting f-l-string-face until the closing " is
there) wasn't perhaps quite so bad after all.

> When code is syntactically incorrect, it's common/normal/expected for
> the highlighting to be "incorrect".

Where "incorrect" here means "different from what it would be if the code
were correct".

> This "incorrect" behavior is actually a good way for the user to notice
> that his code has problems.

Agreed, totally.

> So, from this point of view, there's no need to highlight the opening
> string quote with f-l-warning-face: just looking back in the buffer
> until you find the first char that is not font-locked as expected will
> find the culprit without any need for any extra elisp code, and
> moreover this method will work in many more cases.

> In other words, messed-up highlighting for incorrect code is just as
> good if not better than explicitly recognizing the incorrect code and
> highlighting it with f-l-warning-face.

I was thinking of "compatibility" with unterminated strings in normal
code.  But they're not the same thing.  An open string in a #define is
perfectly valid code, if somewhat unusual outside of the Obfuscated C
competition.

You've persuaded me that the existing fontification is actually better.
So I won't be committing yesterday's patch.  Thanks!

I'll just finish the other patch and commit that.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).






  reply	other threads:[~2009-05-19 10:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13  6:39 bug#3269: 23.0.93; C-mode text highlighting Thomas Christensen
2009-05-14  9:28 ` Andreas Schwab
2009-05-14 21:39 ` Alan Mackenzie
2009-05-18 15:06   ` Alan Mackenzie
2009-05-18 15:06   ` Alan Mackenzie
2009-05-18 15:06   ` Alan Mackenzie
2009-05-18 16:41     ` Chong Yidong
2009-05-18 16:41     ` Chong Yidong
2009-05-18 21:16       ` Alan Mackenzie
2009-05-18 21:16       ` Alan Mackenzie
2009-05-18 21:16       ` Alan Mackenzie
2009-05-18 16:41     ` Chong Yidong
2009-05-18 19:53     ` Stefan Monnier
2009-05-18 19:53     ` Stefan Monnier
2009-05-18 19:53     ` Stefan Monnier
2009-05-18 21:30       ` Alan Mackenzie
2009-05-19  2:24         ` Stefan Monnier
2009-05-19  2:24         ` Stefan Monnier
2009-05-19 10:26           ` Alan Mackenzie [this message]
2009-05-19 10:26           ` Alan Mackenzie
2009-05-19 14:36             ` Stefan Monnier
2009-05-19 22:40               ` Alan Mackenzie
2009-05-19 22:40               ` Alan Mackenzie
2009-05-19 22:40               ` Alan Mackenzie
2009-05-19 14:36             ` Stefan Monnier
2009-05-19 14:36             ` Stefan Monnier
2009-05-19 10:26           ` Alan Mackenzie
2009-05-20 10:31           ` Jim Meyering
2009-05-19  2:24         ` Stefan Monnier
2009-05-18 21:30       ` Alan Mackenzie
2009-05-18 21:30       ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20090519102619.GA1317__3611.90801854736$1242730357$gmane$org@muc.de' \
    --to=acm@muc.de \
    --cc=3269@emacsbugs.donarmstrong.com \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=thomasc@thomaschristensen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.