GNU bug report logs -
#23901
CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings
Previous Next
Full log
View this message in rfc822 format
Hello, Jostein.
On Thu, Jul 07, 2016 at 10:22:24AM +0200, Jostein Kjønigsen wrote:
> On Wed, Jul 6, 2016, at 11:02 PM, Alan Mackenzie wrote:
> > Certainly, yes. But maybe it might be simpler if you could describe the
> > two test cases that fail, and how to reproduce the failures starting from
> > emacs -Q, loading csharp-mode. I've got a copy of the csharp-mode
> > repository, including the testing files.
> >> --
> >> Jostein Kjønigsen
> >> jostein <at> kjonigsen.net / jostein <at> secure.kjonigsen.net
> > --
> > Alan Mackenzie (Nuremberg, Germany).
> Thanks for your reply. I certainly agree about your suggestion.
> I think the absolutely simplest approach is to just observe the
> fontification of the test-document visually, with and without your patch
> applied.
OK. Given that the file is small, this seems reasonable.
> To see how the document -should- be fontified, run Emacs without any
> patches or modifications to cc-defs.
I see the same problems regardless of my latest proposed patch to
cc-langs.el.
> Then open csharp-mode.el, and run 'M-x eval-buffer'. csharp-mode should
> now be fully loaded and initialised.
> After doing this, just try opening the test-document
> "test-files/fontification-test.cs".
> It should be fairly obvious from the file what correct fontification
> should be like.
I see that the backslash at the end of the Literal2 string acts as an
escape character, causing the following lines to get mis-fontifified.
> Now exit Emacs, apply your patch to cc-langs.el, and retry the procedure
> outlined above. You should now observe that fontification of the
> test-document no longer is applied correctly.
> I cannot really see how that patch, in cc-langs.el could affect this
> code so directly, but on the other hand it's hard to argue with what you
> see.
> Any ideas on what's going on here? While "fixing" csharp-mode is
> obviously not going to be your job, you may see things happening, and
> extrapolate how that may apply to other third-party cc-mode
> derivatives... And if your patch should be deemed safe or not.
Yes, I have a good idea as to what's going wrong. The backslash is not
getting marked with a syntax-table text property. The reason for this
is, I think, that csharp-mode is trying to use
`syntax-propertize-function' to do this. The problem is that nothing is
triggering a call to this function. This is one of the reasons that the
CC Mode core doesn't use the `syntax-propertize-function' mechanism - it
is fairly random when and whether it gets run. Officially it describes
itself as a "lazy" function, as if that were a positive aspect.
I would recommend you to replace csharp-mode-syntax-propertize-function
with a function to be called directly from after-change-functions, and
to place this function in the csharp-mode value of
`c-before-font-lock-functions'. It should be clear enough from
`c-before-font-lock-functions''s doc string, and from the existing
functions for other modes (including Java Mode) how this should work. A
similar function to be called from before-change-functions could be
placed on `c-get-state-before-change-functions', but I don't think you
will need this.
> csharp-mode has a history for having weird hacks, but we're trying to
> get rid of them as much as possible. Hopefully this isn't one of those
> hacks causing (more) compatibility concerns than a maintainer should
> have to worry about...
Let's hope not!
> --
> Jostein Kjønigsen
> jostein <at> kjonigsen.net / jostein <at> secure.kjonigsen.net
--
Alan Mackenzie (Nuremberg, Germany).
This bug report was last modified 8 years and 355 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.