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

6. Major and Minor Modes

XEmacs is language sensitive. It has several major and minor modes. The major modes customize Emacs to edit text of a particular sort. There are major modes for C, Lisp, Emacs Lisp, LaTeX, English etc. Within each major mode, certain functions and keys are redefined to "suit" that particular sort of text. The minor modes provide certain features which can be turned off or on at any time. Emacs can only be in one major mode at any time, but it can turn on several minor modes at the same time. After you have selected any major or minor mode, you can select Describe Mode from the Help menu and you will get documentation about those modes.

6.1 Major Modes  Choosing Major Modes
6.2 Minor Modes  Auto-Fill, Abbrev and other minor modes


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

6.1 Major Modes

Emacs has several major modes which customize Emacs to edit text of various sorts. You can have only one major mode at any time. Within each major mode, Emacs redefines certain functions (like cursor movement, indentation and text killing) to suit the needs of the text being edited. When you are editing a specific type of text you should switch to the appropriate mode. If you are working with C code, you should switch to C mode; if you are working with Lisp code, then switch to lisp mode and if you are working with English text switch to Text mode.

When you open a file to work on, Emacs usually selects the appropriate mode. For example, if you open a file called `guide.c' then Emacs will select the C mode because of the ".c" extension of the file. To explicitly select a mode type the following command:

 
;;; selects lisp mode
M-x lisp-mode

;;; selects C mode
M-x c-mode

To select any other mode, just add the major mode name before the '-mode'. The current mode in which you are in will be displayed in parenthesis in the mode-line at the bottom of the frame. All major modes have some special keybindings and you can get a listing of those keybindings by selecting List Keybindings from the Help menu on the menu bar.

Some of the available modes in XEmacs are :

fundamental-mode
When you start XEmacs, usually you start with the default "Fundamental" mode. This mode has no special definitions or settings.

nroff-mode
Use this mode when you have to format a text with nroff before it can be available in readable form. It redefines some indentation commands. See section `Nroff Mode' in XEmacs User's Manual, for information on this mode.

tex-mode
Use this mode if you are using the LaTeX text-formatter. It provides commands for insertion of quotes, braces and other characters. It also allows you to format the buffer for printing. See section `TeX Mode' in XEmacs User's Manual, for information on this mode.

texinfo-mode
Texinfo is a documentation system that uses a single source file to produce both printed output and on-line documentation. When you use this mode, there will be some special keybindings for inserting some characters and executing some commands.

This info file which you are reading right now is produced by 'Texinfo'

outline-mode
Use this mode for editing outlines. When you enable this mode, you can make part of the text temporarily invisible so that you can see the overall structure of the outline. See section `Outline Mode' in XEmacs User's Manual, for information on this mode.

c-mode
Use this mode for C programs. It will redefine some indentation commands. See section `C Indent' in XEmacs User's Manual.

lisp-mode
Use this mode for Lisp programs. Look at the XEmacs User's Manual for more information.

fortran-mode
Use this mode for Fortran programs. This mode provides special commands to move around and some other indentation commands. For more information on this mode, See section `Fortran' in XEmacs User's Manual.

edit-picture
This is the picture mode which you can use to create a picture out of text characters. See section `Picture' in XEmacs User's Manual, for more information.

asm-mode
Use asm-mode for editing files of assembler code. Look at the file ` /usr/local/lib/xemacs-VERSION/lisp/modes/asm.el' for more information.

There are some other modes and commands for working with other kinds of text or programs. Emacs also provides commands for reading and sending Mail. For more information on these features look at the XEmacs Manual. Emacs also provides the functions of a desk calendar, with a diary of past or planned events. For more information on the calendar mode look at the manual for Calendar Mode and Diary.


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

6.2 Minor Modes

The minor modes in Emacs provide some optional features which you can turn on or off. Any number of minor modes can be active at the same time with any major mode. You can enable a minor mode in one buffer and disable it in other mode. To enable a minor mode, for example the font-lock mode type the following command:

 
M-x font-lock-mode
To enable the other minor modes, replace the "font-lock" with the name of the minor mode. To disable the mode type the command again. A positive argument will always turn the mode on. Whenever you type this command, it will turn the mode on if it was off, OR it will turn it off if it was on i.e. it toggles. Look at the mode-line at the bottom of the frame. If it says FLock in parentheses, then it means that this mode is on, otherwise it is off.

The following are some of the minor modes available in XEmacs. To enable any one of them type "M-x" in front of them.

font-lock-mode

You can also choose this mode by selecting the Syntax Highlighting menu item from the Options menu on the menu-bar at the top. If you wish to have this mode enabled permanently, choose Save Options from the Options menu. See section 2.2.3 The Options Menu, for more information on the Options menu. You can also add statements in your `init.el' file. For each major mode in which you wish to enable this minor mode, you need a statement in your `init.el' file. The following example shows how to enable the font-lock mode when the major mode is c-mode.

 
(add-hook 'c-mode-hook          'turn-on-font-lock)

See section 8. Other Customizations.

When you enable this mode, the text will be displayed in different colors and fonts depending on the type of the text. This makes the text very easy to read and understand. For example, comments might be displayed in red, variables in black, functions in blue and other keywords in different colors and fonts. When you select More from the Syntax Highlighting option, you get very detailed display of colors and fonts; function names within comments themselves might appear in a different font and color.

auto-fill-mode
Enabling this mode will provide automatic word-wrapping. The SPC key will break lines i.e. insert newlines as you type to prevent lines from becoming too long.

overwrite-mode
When you enable this mode, the text that you type will replace the existing text rather than moving it to the right (the default case). You can enable this mode by selecting Overstrike menu-item from the Options menu from the menu-bar.

abbrev-mode
After you enable this mode, you can define words which will expand into some different text i.e. you can define abbreviations. For example, you might define "expand" to "expand will eventually expand to this text". After this definition you will be able to get "expand will eventually expand to this text" simply by typing

 
expand SPC 

See section `Abbrevs' in XEmacs User's Manual, for more information on this mode and on defining abbreviations.

auto-save-mode
After you enable this mode in a buffer, the contents of that buffer will be saved periodically. This will reduce the amount you might lose in case of a system crash.

line-number-mode
After you enable this mode, the line number at which your cursor is present will be displayed continuously in the mode line.

blink-paren
To enable this command, just type
 
M-x blink-paren

Do not add the "-mode" to it. You can also select the Paren Highlighting option from the Options menu. After you enable this command, put your cursor on one of the left parenthesis. The other matching parenthesis will start blinking. See section 2.2.3 The Options Menu, for more information on the Paren Highlighting option.

For information on some other modes, look at the XEmacs User's Manual and the associated files.


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

This document was generated by XEmacs Webmaster on August, 3 2012 using texi2html