GNU bug report logs - #23901
CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings

Previous Next

Package: cc-mode;

Reported by: Åsmund Grammeltvedt <asmundg <at> big-oil.org>

Date: Tue, 5 Jul 2016 20:04:02 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #31 received at 23901 <at> debbugs.gnu.org (full text, mbox):

From: Vasilij Schneidermann <v.schneidermann <at> gmail.com>
To: Alan Mackenzie <acm <at> muc.de>
Subject: Re: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of
 fallthrough switch/case with strings
Date: Thu, 7 Jul 2016 15:13:53 +0200
Hello,

> 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 doubt this is related as I've changed csharp-mode.el to include the
standard definition for c-nonlabel-token-key minus the string delimiter
parts and that made the broken tests work again.  Judging from my
previous experiences with `syntax-propertize-function', unexpected
interactions can arise from  other places, including the use of
`font-lock-syntactic-keywords'.  FWIW, I wouldn't rule out an old
csharp-mode.elc that's still around or an incorrectly compiled cc-mode.

I also doubt that `syntax-propertize-function' is unreliable.  If you
trace from its definition backwards through the sources of
fontification-related files, you'll notice that it is triggered on
initial fontification of a region and after buffer modifications.

Yes, laziness is a positive aspect.  I'd expect it to be self-evident
that avoiding any more work than needed for refontification is important
for performant display and editing of code.  Why would that not apply
for modes derived from cc-mode?

> 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.

This sounds wrong as font-lock is already doing this in a less ad-hoc
way.  Reusing its API for that solves problems such as having a
specified region to refontify after changes (otherwise one would need to
guess a suitable one with `after-change-functions' or worse, use the
entire buffer).  Why exactly would I want to avoid it?

Cheers
Vasilij




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.