keyongtech


  keyongtech > lisp > 03/2009

 #1  
03-10-09, 12:45 PM
Xah Lee
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/

☄
 #2  
03-10-09, 01:43 PM
Tassilo Horn
Xah Lee <xahlee> 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
 #3  
03-10-09, 08:59 PM
Xah Lee
Xah Lee <xah> 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 <tass> 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/

☄
 #4  
03-10-09, 10:01 PM
W Dan Meyer
Xah Lee <xahlee> writes:

> Xah Lee <xah> wrote:
>>

> On Mar 10, 6:43 am, Tassilo Horn <tass> wrote:
>
> I see. Thanks.
>> 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
[..]
Similar Threads
Emacs lisp-mode indentation for keyword arguments

Suppose I type (foo :a a :b b :c c :d :e e :f f :g g) into a Lisp buffer (keyword names are deliberately short, but imagine they would not fit on a line). C-M-q...

Nested Lambda function gives error in common lisp, guile, emacs lisp but works in scheme. Why?

Please explain the below errors: guile> (((lambda (a) (lambda (b) (list a b))) 1) 2) (1 2) i i i i i i i ooooo o ooooooo ooooo ooooo I I I I I I I ...

Tab-completion (for CLISP) in inferior-lisp-mode in Emacs; possible?

I just have started playing with CLISP. Running at the shell, I can use <TAB> for completion e.g *inspect-brow<TAB> expands to *inspect-browser* I prefer to run CLISP...

Emacs or Slime Lisp Syntax High lighting

Does anyone know how to enable Slime or emacs syntax highlighting of lisp code? I am using a mac, and having trouble finding any reference for this in just emacs. I have...

Emacs Lisp & Common Lisp

A question: If I try to learn Emacs Lisp while also learning Common Lisp, am I going to damage my understanding of either in some way?


All times are GMT. The time now is 11:24 PM. | Privacy Policy