Comment 12 for bug 961231

Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 961231] Re: Broken font-locking

On Mar 23, 2012, at 08:56 AM, Andreas Roehler wrote:

>Am 23.03.2012 00:48, schrieb Barry Warsaw:
>> Another one:
>>
>>
>> 'hello {0}'.format('world')
>>
>>
>> The word 'format' gets py-builtins-face but in this case it should just be the default face because it's acting as an attribute, not a built-in.
>>
>
>I'm afraid we have reached the limits of current implementation.
>
>Emacs get's noticed about builtins via hard-coded strings.
>
>a builtin is a builtin
>
>
>Maybe maintain this as a feature request, in which circumstances builtins
>should treated different and how?
>
>However, don't see any chance for now. Altogether as we have already a speed
>issue.

Would it be possible to do a negative lookbehind for '.'?

IOW, if you see

   [.]<somebuiltin>

then it's being used as an attribute, but if you just see

   [^.]<somebuildin>

then you can assume it's a built in. Or alternatively, something like:

   (^|[ \t])<somebuiltin>

Or maybe in English: if the builtin symbol starts at the beginning of the line
or is preceded by whitespace, give it py-builtins-face, otherwise give it
default face.