From: Xah Lee
Subject: how is emacs lisp syntax colored in emacs-lisp-mode?
Date: 
Message-ID: <d745358e-b362-4890-b392-cc7d6b1bfe0f@e1g2000pra.googlegroups.com>
when coding elisp, lately i find myself using camelCase style for my
own function and variable names. Because i find that easier to
distinguish from built-in function/var/keywords.

on thinking about this, i thought it would not be necessary if emacs-
lisp-mode would just color all built in functions and variables.
However, the way it is syntax colored seems strange, unlike in most
major modes for langs where each class of keywords gets one color.

for example, these keywords would be colored purple by default:

 defun, lambda, while, if, progn, save-restriction, ...

while the following built-in keywords are uncolored (black):
narrow-to-region, mapc, goto-char, point-min, search-forward, car,
nil, replace-match ... etc.

is there a principle of how the keywords are colored?

thanks

  Xah
∑ http://xahlee.org/

☄

From: Tassilo Horn
Subject: Re: how is emacs lisp syntax colored in emacs-lisp-mode?
Date: 
Message-ID: <873adl333w.fsf@thinkpad.tsdh.de>
Xah Lee <······@gmail.com> writes:

Hi Xah,

> on thinking about this, i thought it would not be necessary if emacs-
> lisp-mode would just color all built in functions and variables.
> However, the way it is syntax colored seems strange, unlike in most
> major modes for langs where each class of keywords gets one color.
>
> for example, these keywords would be colored purple by default:
>
>  defun, lambda, while, if, progn, save-restriction, ...

That's the case, isn't it?

> while the following built-in keywords are uncolored (black):
> narrow-to-region, mapc, goto-char, point-min, search-forward, car,
> nil, replace-match ... etc.

Function names like the ones you listed aren't colored in function calls
unless they're one of the special forms you mentioned before.

> is there a principle of how the keywords are colored?

Yes, see the elisp manual:

,----[ (info "(elisp)Levels of Font Lock") ]
| Many major modes offer three different levels of fontification.  You
| can define multiple levels by using a list of symbols for KEYWORDS in
| `font-lock-defaults'.  Each symbol specifies one level of
| fontification; it is up to the user to choose one of these levels,
| normally by setting `font-lock-maximum-decoration' (*note Font Lock:
| (emacs)Font Lock.).  The chosen level's symbol value is used to
| initialize `font-lock-keywords'.
| 
|    Here are the conventions for how to define the levels of
| fontification:
| 
|    * Level 1: highlight function declarations, file directives (such as
|      include or import directives), strings and comments.  The idea is
|      speed, so only the most important and top-level components are
|      fontified.
| 
|    * Level 2: in addition to level 1, highlight all language keywords,
|      including type names that act like keywords, as well as named
|      constant values.  The idea is that all keywords (either syntactic
|      or semantic) should be fontified appropriately.
| 
|    * Level 3: in addition to level 2, highlight the symbols being
|      defined in function and variable declarations, and all builtin
|      function names, wherever they appear.
`----

Bye,
Tassilo
From: Xah Lee
Subject: Re: how is emacs lisp syntax colored in emacs-lisp-mode?
Date: 
Message-ID: <2eeaef93-78b5-4dcb-b7fe-9abb03b04424@f1g2000prb.googlegroups.com>
Xah Lee <······@gmail.com> wrote:
> on thinking about this, i thought it would not be necessary if emacs-
> lisp-mode would just color all built in functions and variables.
> However, the way it is syntax colored seems strange, unlike in most
> major modes for langs where each class of keywords gets one color.

> for example, these keywords would be colored purple by default:

>  defun, lambda, while, if, progn, save-restriction, ...
> while the following built-in keywords are uncolored (black):
> narrow-to-region, mapc, goto-char, point-min, search-forward, car,
> nil, replace-match ... etc.

On Mar 10, 6:43 am, Tassilo Horn <·······@member.fsf.org> wrote:
> Function names like the ones you listed aren't colored in function calls
> unless they're one of the special forms you mentioned before.

I see. Thanks.

> > is there a principle of how the keywords are colored?
>
> Yes, see the elisp manual:
>
> ,----[ (info "(elisp)Levels of Font Lock") ]
> | Many major modes offer three different levels of fontification...
> ...

does emacs-lisp-mode support more than level 1?

i have my emacs set to level 2. I tried customize-group on emacs-lisp-
mode but that doesn't seem available. I tried to set font-lock-maximum-
decoration to 3 but that doesn't seems to have effect.

  Xah
∑ http://xahlee.org/

☄
From: W Dan Meyer
Subject: Re: how is emacs lisp syntax colored in emacs-lisp-mode?
Date: 
Message-ID: <87hc2111gs.fsf@gmail.com>
Xah Lee <······@gmail.com> writes:

> Xah Lee <······@gmail.com> wrote:
>> on thinking about this, i thought it would not be necessary if emacs-
>> lisp-mode would just color all built in functions and variables.
>> However, the way it is syntax colored seems strange, unlike in most
>> major modes for langs where each class of keywords gets one color.
>
>> for example, these keywords would be colored purple by default:
>
>>  defun, lambda, while, if, progn, save-restriction, ...
>> while the following built-in keywords are uncolored (black):
>> narrow-to-region, mapc, goto-char, point-min, search-forward, car,
>> nil, replace-match ... etc.
>
> On Mar 10, 6:43 am, Tassilo Horn <·······@member.fsf.org> wrote:
>> Function names like the ones you listed aren't colored in function calls
>> unless they're one of the special forms you mentioned before.
>
> I see. Thanks.
>
>> > is there a principle of how the keywords are colored?
>>
>> Yes, see the elisp manual:
>>
>> ,----[ (info "(elisp)Levels of Font Lock") ]
>> | Many major modes offer three different levels of fontification...
>> ...
>
> does emacs-lisp-mode support more than level 1?
>
> i have my emacs set to level 2. I tried customize-group on emacs-lisp-
> mode but that doesn't seem available. I tried to set font-lock-maximum-
> decoration to 3 but that doesn't seems to have effect.

Yes, because font-lock-maximum-decoration is usually set (as for my CVS
Emacs) to t, which indicate the highest possible level.
W Dan

>
>   Xah
> ∑ http://xahlee.org/
>
> ☄