Emacs also has major modes for the programming languages Lisp, Scheme (a variant of Lisp), Awk, C, C++, Fortran, Icon, Java, Objective-C, Pascal, Perl, Pike, CORBA IDL, and Tcl. There is also a major mode for makefiles, called Makefile mode. An second alternative mode for Perl is called CPerl mode.
Ideally, a major mode should be implemented for each programming language that 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 forms of Lisp mode, which differ in the way they interface to Lisp execution. See Executing Lisp.
Each of the programming language major modes defines the
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-j is normally defined to do
RET followed by
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. Use C-b C-d to delete a tab character before point,
in these modes.
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 runs a normal hook called the mode hook,
which is the value of a Lisp variable. Each major mode has a mode hook,
and the hook's name is always made from the mode command's name by
-hook'. For example, turning on C mode runs the hook
c-mode-hook, while turning on Lisp mode runs the hook
lisp-mode-hook. See Hooks.