Emacs has specialized major modes (see Major Modes) for many
programming languages. A programming language mode typically
specifies the syntax of expressions, the customary rules for
indentation, how to do syntax highlighting for the language, and how
to find the beginning or end of a function definition. It often has
features for compiling and debugging programs as well. The major mode
for each language is named after the language; for instance, the major
mode for the C programming language is
Ideally, Emacs should have a major mode for each programming language that you might want to edit. If it doesn't have a mode for your favorite language, the mode might be implemented in a package not distributed with Emacs (see Packages); or you can contribute one.
In most programming languages, indentation should vary from line to
line to illustrate the structure of the program. Therefore, in most
programming language modes, typing <TAB> updates the indentation
of the current line (see Program Indent). Furthermore, <DEL>
is usually bound to
deletes backward treating each tab as if it were the equivalent number
of spaces, so that you can delete one column of indentation without
worrying whether the whitespace consists of spaces or tabs.
Entering a programming language mode runs the custom Lisp functions
specified in the hook variable
prog-mode-hook, followed by
those specified in the mode's own mode hook (see Major Modes).
For instance, entering C mode runs the hooks
c-mode-hook. See Hooks, for information about hooks.
The Emacs distribution contains Info manuals for the major modes for Ada, C/C++/Objective C/Java/Corba IDL/Pike/AWK, and IDLWAVE. For Fortran mode, see Fortran.