unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
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: Mon, 18 May 2009 22:24:02 -0400	[thread overview]
Message-ID: <jwvk54d262g.fsf-monnier+emacsbugreports__10943.2004894645$1242700353$gmane$org@gnu.org> (raw)
In-Reply-To: <20090518213030.GD12920@muc.de> (Alan Mackenzie's message of "Mon, 18 May 2009 21:30:30 +0000")

>> > OK, here is a patch for half of the problem - it now fontifies a broken
>> > string in a #define properly
>> For some definition of "properly".
> 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.  ;-)

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.

When code is syntactically incorrect, it's common/normal/expected for
the highlighting to be "incorrect".  This "incorrect" behavior is
actually a good way for the user to notice that his code has problems.
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.

When I introduced the use of f-l-warning-face in C strings, it was not
to avoid messed-up highlighting, but rather to avoid apparently correct
highlighting for code that was actually incorrect/unportable (and even
accepted by GCC at that time).

>> I think this part is more important.  I don't care much (if at all)
>> about how invalid code is highlighted.
> I agree it's important.  I've got it working; what's more, the code
> doesn't advise any of the font lock functions for (>= emacs-major-version
> 22).  I'll commit it tomorrow sometime.

Thanks,


        Stefan






  parent reply	other threads:[~2009-05-19  2:24 UTC|newest]

Thread overview: 21+ 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
     [not found]   ` <20090518150643.GA12920@muc.de>
2009-05-18 16:41     ` Chong Yidong
2009-05-18 16:41     ` Chong Yidong
2009-05-18 19:53     ` Stefan Monnier
2009-05-18 19:53     ` Stefan Monnier
     [not found]     ` <87iqjygy8e.fsf@cyd.mit.edu>
2009-05-18 21:16       ` Alan Mackenzie
2009-05-18 21:16       ` Alan Mackenzie
     [not found]     ` <jwv7i0eb3e8.fsf-monnier+emacsbugreports@gnu.org>
2009-05-18 21:30       ` Alan Mackenzie
2009-05-18 21:30       ` Alan Mackenzie
     [not found]       ` <20090518213030.GD12920@muc.de>
2009-05-19  2:24         ` Stefan Monnier
2009-05-19  2:24         ` Stefan Monnier [this message]
     [not found]         ` <jwvk54d262g.fsf-monnier+emacsbugreports@gnu.org>
2009-05-19 10:26           ` Alan Mackenzie
2009-05-19 10:26           ` Alan Mackenzie
     [not found]           ` <20090519102619.GA1317@muc.de>
2009-05-19 14:36             ` Stefan Monnier
2009-05-19 14:36             ` Stefan Monnier
     [not found]             ` <jwvd4a5yxck.fsf-monnier+emacsbugreports@gnu.org>
2009-05-19 22:40               ` Alan Mackenzie
2009-05-19 22:40               ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='jwvk54d262g.fsf-monnier+emacsbugreports__10943.2004894645$1242700353$gmane$org@gnu.org' \
    --to=monnier@iro.umontreal.ca \
    --cc=3269@emacsbugs.donarmstrong.com \
    --cc=acm@muc.de \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).