Next: , Previous: , Up: Top   [Contents][Index]


8 Other Customizations

You can modify the behavior of Emacs in minor ways permanently by putting your changes in your init.el file. This file contains Lisp function call expressions. Each of these expressions will consist of a function name followed by arguments, all surrounded by parentheses. For example, to turn on the auto-fill-mode (i.e. break lines automatically when they become too long) , put the following line in your init.el file:

(add-hook 'text-mode-hook
        '(lambda() (auto-fill-mode 1)))

Emacs has a function named "turn-on-auto-fill" which is defined as "(lambda() (auto-fill-mode 1))". Therefore you can also write the above as:

(add-hook 'text-mode-hook 'turn-on-auto-fill)

Emacs provides a number of hooks for the sake of customization. The hook variables contain list of functions to be called with no arguments. To turn on the auto-fill-mode, add the appropriate hook as shown in the example above.

Similarly, to enable the "font-lock mode" which displays your program in different fonts and colors(see Modes), put the following in your init.el file. The comments above the statement explain what the statements do.

;;; enables the font-lock-mode in Lisp Mode
(add-hook 'lisp-mode-hook    'turn-on-font-lock)

;;; enables the font-lock-mode in Texinfo Mode
(add-hook 'texinfo-mode-hook    'turn-on-font-lock)

;;; enables the font-lock mode in C Mode
(add-hook 'c-mode-hook          'turn-on-font-lock)

To turn on the font-lock mode in other Major Modes like emacs-lisp, just put the name of the mode with "-hook" appended to it as the middle parameter in the above examples. You can also select the color that the functions, comments or other keywords should be displayed in :

;;; the function names will now be displayed in blue color
(set-face-foreground 'font-lock-function-name-face "blue")

;;; the comments will be displayed in forest green
 (set-face-foreground 'font-lock-comment-face "forest green")

For other customizations regarding the font-lock face, look at the file /usr/local/lib/sxemacs-VERSION/etc/sample.init.el.


Next: , Previous: , Up: Top   [Contents][Index]