[ < ] [ > ]   [ << ] [ 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 section Major and Minor 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/xemacs-VERSION/etc/sample.init.el’.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Other Customizations

In XEmacs, variables are used for internal record-keeping and customizations. There are some variables called "options" which you can use for customizations. To examine a variable use:

 
;;; print the value and documentation of the variable, use either of the
;;; following commands
C-h v
M-x describe variable

After you type any of the above commands, you will be prompted for a variable name in the echo area. Type in the name of the variable, for example, type case-fold-search <RET> Your window will split into two and you will see the following message in that window:

 
case-fold-search's value is t
This value is specific to the current buffer.

Documentation:
*Non-nil if searches should ignore case.
Automatically becomes buffer-local when set in any fashion.

Since this variable’s value is ’t’ searches will ignore case. If you want case-sensitive-search (i.e. if you are searching for "Foo" and you do not want "foo" to be included in the search, you need to set this variable to "nil". In order to do that, use:

 
M-x set-variable

Emacs will prompt you for the variable which you wish to set. Type in "case-fold-search" and hit <RET>. You will see the following message:

 
Set case-fold-search to value:

Type "nil" and hit <RET>. Now if you again use M-x describe variable , you will see that the new value of case-fold-search will be "nil" and your searches will be case-sensitive. This will be effective only for that Emacs session. If you want to change the value of a variable permanently put the following statement in your ‘init.el’ file :

 
(setq case-fold-search nil)

This statement will make searches case-sensitive only in the current buffer which is the ‘init.el’ file. This will not be very useful. To make searches case-sensitive globally in all buffers, use:

 
(setq-default case-fold-search nil)

If you want to change the value of any other variable, use :

 
(setq <variable-name> <new value>)

"setq" will assign the "new value" to the "variable-name" .

If you want a list of the "options" i.e. the variables available for customization type:

 
;;; displays a buffer listing names, values and documentation of options
M-x list-options

;;; displays options and allows you to edit those list of options
M-x edit-options

Try these options. If you are using edit-options to edit a variable, just point at the variable you wish to edit and use one of the following commands:

1

Set the value of the variable to t (non-nil).

0

Set the value of the variable to nil.

n

Move to the next variable.

p

Move to the previous variable.

There are some other options available to make the value of a variable local to a buffer and then to switch to its global value. You can also have a local variables list in a file which specifies the values to use for certain Emacs variables when you edit that file. See (xemacs)Variables section ‘Variables’ in XEmacs User’s Manual, for information on these options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 Init File Examples

For customizing Emacs, you need to put Lisp expressions in your ‘init.el’ file. The following are some useful Lisp expressions. If you find any of them useful, just type them in your ‘init.el’ file:

For more information on initializing your ‘init.el’ file, See (xemacs)Init File section ‘Init File’ in XEmacs User’s Manual. You should also look at ‘/usr/local/lib/xemacs-VERSION/etc/sample.init.el’, which is a sample ‘init.el’ file. It contains some of the commonly desired customizations in Emacs.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Aidan Kehoe on December 27, 2016 using texi2html 1.82.