Re: CC Mode multi-line strings [Was: Adding Vala support]
Alan Mackenzie <[email protected]>
| Newsgroups | gmane.emacs.cc-mode.general |
|---|---|
| Message-ID | <YZeNJBpdmSLNSSU6@ACM> |
Hello, Theo. On Thu, Nov 18, 2021 at 20:31:59 +0100, Theodor Thornhill wrote: > Hi Alan! > > No problem! My guess is that inside the @" string, there are no escape > > characters. So "\u0063" stands for the six characters \ u 0 0 6 3 > > rather than the single unicode c. If that's the case, then this isn't a > > problem with C# Mode or CC Mode. > Hmm, that might be true, however I think there still is a problem > somewhere. Yes. Apologies for not looking at the attached picture. (I read my email in mutt on a tty, usually.) > For example: > ``` > var x = "Hello, \"World\""; > ``` > In this case, `Hello, \"` is fontified as a string, then `World \"` has > no fontification, then, the last `"` has a warning face, then at last, > the `;` is fontified as a string. I downloaded the current csharp-mode from github, and I think the settings for the c-ml-string-... are not quite right. For example, in c-ml-string-opener-re, there is no "@" in it. I don't think this particular regexp need be complicated. Why won't a simple "\\(@\\(\"\\)\\)" do? (Sorry, I'm not practiced at the rx form of regexps.) In c-ml-string-back-closer-re, it looks like : and ? may have got swapped in "\\(:?" - shouldn't that be "\\(?:"? Indeed, looking back at some earlier versions of my files, I think I can see the origin of some of these discrepanceies. ;-) > This will cause the next expressions to be fontified as strings as > well, possibly rendering the whole file as a string. It seems to make > no difference if the string is preceeded with a `@`. It seems like > escaping quotes is not working properly somehow. See above. > What am I missing :)? These regexps are quite a tricky part of CC Mode. Sorry about that. > All the best, > Theo! -- Alan Mackenzie (Nuremberg, Germany).