Re: bug#3269: 23.0.93; C-mode text highlighting
Alan Mackenzie <[email protected]>
| Newsgroups | gmane.emacs.devel,gmane.emacs.pretest.bugs |
|---|---|
| Message-ID | <[email protected]> |
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).