(lemacs.info)Program Modes


Next: Lists Prev: Programs Up: Programs

Major Modes for Programming Languages
=====================================

   Emacs has several major modes for the programming languages Lisp,
Scheme (a variant of Lisp), C, Fortran, and Muddle.  Ideally, a major
mode should be implemented for each programming language you might want
to edit with Emacs; but often the mode for one language can serve for
other syntactically similar languages.  The language modes that exist
are those that someone decided to take the trouble to write.

   There are several variants of Lisp mode, which differ in the way they
interface to Lisp execution.  Note: Lisp Modes.

   Each of the programming language modes defines the TAB key to run an
indentation function that knows the indentation conventions of that
language and updates the current line's indentation accordingly.  For
example, in C mode TAB is bound to `c-indent-line'.  LFD is normally
defined to do RET followed by TAB; thus it, too, indents in a
mode-specific fashion.

   In most programming languages, indentation is likely to vary from
line to line.  So the major modes for those languages rebind DEL to
treat a tab as if it were the equivalent number of spaces (using the
command `backward-delete-char-untabify').  This makes it possible to
rub out indentation one column at a time without worrying whether it is
made up of spaces or tabs.  In these modes, use `C-b C-d' to delete a
tab character before point.

   Programming language modes define paragraphs to be separated only by
blank lines, so that the paragraph commands remain useful.  Auto Fill
mode, if enabled in a programming language major mode, indents the new
lines which it creates.

   Turning on a major mode calls a user-supplied function called the
"mode hook", which is the value of a Lisp variable.  For example,
turning on C mode calls the value of the variable `c-mode-hook' if that
value exists and is non-`nil'.  Mode hook variables for other
programming language modes include `lisp-mode-hook',
`emacs-lisp-mode-hook', `lisp-interaction-mode-hook',
`scheme-mode-hook', and `muddle-mode-hook'.  The mode hook function
receives no arguments.


automatically generated by info2www