[Top][All Lists]

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

Re: how is emacs lisp syntax colored in emacs-lisp-mode?

From: Tassilo Horn
Subject: Re: how is emacs lisp syntax colored in emacs-lisp-mode?
Date: Tue, 10 Mar 2009 14:43:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

Xah Lee <address@hidden> 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.


reply via email to

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