On 03/20/2015 09:30 AM, Alan Mackenzie wrote: > Hello, Stefan. > > On Thu, Mar 19, 2015 at 04:56:16PM -0400, Stefan Monnier wrote: >>>> you can handle fontification from 1,3, or 4 but not from 2. You need to >>>> refine the system you use to keep track of whether we're within >>>> a `union' so that it knows that position 2 is also "within a union". > >>> Well, sort of. The problem I'm facing is that in Dima Kogan's bug >>> #19669, the following construct appears: > >>> 1. enum xxx_xxxx_xxxxxxxxxx_x >>> 2. {XXX_XXXXXX_XXXX_XXX, >>> 3. XXX_XXXXXX_XXX_XXX, >>> 4. XXXX_XXXXX_XXXX_XXX, > >>> Note that the brace on L2 is on the same line as the first XXX_.... > >>> When the user types on line 4, 5, ... here, CC Mode sets the >>> fontification region start to JUST AFTER THE { ON L2. It is essential >>> that Font Lock doesn't change this. > >> There's your problem: your current setup needs the starting point to be >> either before "union" or after the first open brace. >> It breaks down if it's between the two. That's the problem you need to fix. > > Not really. CC Mode is quite capable of handling the Font Lock region > starting at BOL2. The problem is, when that starting point needs to be > after the brace on L2, Font Lock moves the starting point somewhere > else, fouling up the font locking. This is proving surprisingly tough > to fix. I don't understand. Why shouldn't I be able to tell cc-mode to fontify *arbitrary* regions and expect it to correctly apply highlighting to these regions? It's the idea that the region "needs to be after brace" that I find confusing. Shouldn't jit-lock have the right to expand the region arbitrarily?