Subject: Re: bug#16610: 24.3.50; [ruby-mode] Variables named as built-in functions font-locked incorrectly

From: Bozhidar Batsov <[email-masked]>
Date: Sat, 1 Feb 2014 18:47:43 +0200

On Saturday, February 1, 2014 at 6:29 PM, Dmitry Gutov wrote:
> On 01.02.2014 17:31, Bozhidar Batsov wrote:
> > Variables can’t end with ?, so
> > block_given? is always clear. Same goes for exit!. Pretty sure no one
> > will ever name a var __xxx__.
> >  
>  
>  
> Good points.
>  
> > `binding` & `caller` seem the most likely
> > names in the list to cause a problem like `format`, since they’d be good
> > variable names (at least in code making use of metaprogramming).
> >  
>  
>  
> Still not very likely, though (e.g. compared to `format`, which is in  
> every other Rails tutorial). And anyone doing metaprogramming should be  
> aware of these two, and would probably name their vars differently.
>  
> I have a patch ready, but here's what I'm not sure about: if the  
> built-in method that requires arguments is followed by (maybe whitespace  
> and) newline, do we highlight it?
>  
> If yes, we'll have false positives when a local variable with that name  
> is at a line by itself, maybe on the last line of a method, so that its  
> value is returned.
>  
> If no, any such built-in won't be highlighted until the user types in  
> the first argument, which is also suboptimal (if I made a typo, I'll  
> have to go back a longer distance).
>  
>  

I’d say that the second option is better, since it won’t cause false positives.  
This would also take care of an annoying bit regarding the `p` built-in - each time you start
typing something that starts with “p" the “p” briefly gets font-locked as built-in, before the following letter is inserted.