Syntax highlighting

To enable color syntax highlighting in XEmacs one needs to enter in init.el the following line:

(require 'font-lock) ; enable syntax highlighting

By default XEmacs's colors are rather bleak. I prefer to have a dark background, this is a sample of how the colors look like in my XEmacs. (Note: One needs to enable cascading style sheets (CSS) in the web browser to see the colors.) To obtain these colors one needs to insert in custom.el the contents of this file.

Some people prefer a light background. Here is an example, and here is the necessary piece of text to achieve these colors.

Of course, the above needs to be only a first step in setting up the colors. XEmacs has a user-friendly way of changing the colors, fonts, etc, attributes which in XEmacs lingo are called faces. Most colors you saw in the examples above are font-lock faces. To customize them select from the menu on the top of the XEmacs window Options -> Customize -> Emacs -> Faces -> Font Lock Faces -> Font Lock Faces. XEmacs also has a huge number of more obscure faces, to see them all select from the menu Options -> Customize -> Face, and hit the Return key.

By pressing on the small triangle to the right of each face, several lines with radio buttons will open. There one can change the colors, fonts, sizes, etc. After doing that, right-click with the mouse and choose set to apply the changes (non-permanently) and then open a file to see how the colors look like. To save the changed faces for future XEmacs sessions, go back to the list of faces, again right-click with the mouse and choose save.

XEmacs accepts colors by name, that is, green, red, etc, or by their hexadecimal RGB number (like #ff0000 for red, etc). On Unix there is a nifty program called xcolorsel which will show all the available colors, their names and RGB numbers. Otherwise a list of colors can be found here (also mirrored here).


Back: XEmacs tips aoleg@math.umn.edu Created with XEmacs Valid XHTML 1.0! Updated: July 03, 2004