help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to enable font lock for functions called by other functions


From: Nikolaj Schumacher
Subject: Re: How to enable font lock for functions called by other functions
Date: Wed, 13 Aug 2008 13:53:18 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin)

doyoucy@gmail.com wrote:

>> (font-lock-add-keywords
>>    nil `(("\\([[:alpha:]_][[:alnum:]_]*\\)("  1 
>> font-lock-function-name-face)))
>
> I think coloring the inner function name is common practice for many
> code navigation tools, the code above works, but it also applys
> function name face to the keywords like "if" "while".

I hope I mentioned it was a hack? :)
It works for me, because I put spaces before if and while.

(font-lock-add-keywords
 nil `(("\\([[:alpha:]_][[:alnum:]_]*\\)("
        1 font-lock-function-name-face)) t)

could fix this particular issue.

> I'm wondering why emacs don't have an option to enable it.

Most likely the answer to such questions is:  Because nobody has
implemented it.

Doing it properly would probably require Emacs to parse the language,
which it doesn't.  And hacks such as mine fail on many borderline cases
like operator().



regards,
Nikolaj Schumacher




reply via email to

[Prev in Thread] Current Thread [Next in Thread]