Emacs has several major modes (see Major Modes) to support programming languages. These major modes will typically understand language syntax, provide automatic indentation features, syntax based highlighting of text, and will often provide interfaces to the programming environment to assist in compiling, executing and debugging programs.
A language mode exist when someone decides to take the trouble to write it. At this time many widely used programming languages are supported by SXEmacs. Examples include Ada, Awk, C, C++, CORBA (IDL), Fortran, Java, Lisp, Modula 2, Objective-C, Perl, Pike, Prolog, Python, Ruby, Scheme, Simula, SQL, Tcl, Unix Shell scripts, and VHDL. Some of these language have seperate manuals, and some times more than one mode may be available for a language. For example, there are several variants of Lisp mode, which differ in the way they interface to Lisp execution. See Lisp Modes.
Major modes for programming language support are distributed in optional SXEmacs packages (see Packages) that must be installed before use. A notable exception to this rule is that a Lisp Mode is integral to SXEmacs. The Programming Mode Package (prog-modes) contains many such modes. Some languages are supported by packages of their own; prominent examples of such packages include cc-mode for C, C++, Java, Objective C etc., python-modes for Python, and scheme for Scheme.
For a language named lang the major mode for the language will
typically be named
lang-mode. For example, the mode for C
c-mode, that for Bourne shell scripts is called
sh-mode and so on. These modes will invoke the functions listed
in the corresponding hook variables as a last step. See Mode Hooks.
A mode can be invoked by typing M-x lang-mode RET. However this step is not normally required. If the package for a language mode is installed SXEmacs usually knows when to automatically invoke the mode. This is normally done based on examining the file name to determine the language. Choosing 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. 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.