[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

31.1 Major Modes for Programming Languages

Emacs has specialized major modes for various programming languages. @xref{Major Modes}. A programming language major 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 of a function definition. It often customizes or provides facilities for compiling and debugging programs as well.

Ideally, Emacs should provide a major mode for each programming language that you might want to edit; if it doesn't have a mode for your favorite language, you can contribute one. But often the mode for one language can serve for other syntactically similar languages. The major mode for language l is called l-mode, and you can select it by typing M-x l-mode <RET>. Voir la section How Major Modes are Chosen.

The existing programming language major modes include Lisp, Scheme (a variant of Lisp) and the Scheme-based DSSSL expression language, Ada, ASM, AWK, C, C++, Delphi (Object Pascal), Fortran (free format and fixed format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (TeX's companion for font creation), Modula2, Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Python, Simula, Tcl, and VHDL. An alternative mode for Perl is called CPerl mode. Modes are available for the scripting languages of the common GNU and Unix shells, VMS DCL, and MS-DOS/MS-Windows ‘BAT’ files. There are also major modes for editing makefiles, DNS master files, and various sorts of configuration files.

In most programming languages, indentation should vary from line to line to illustrate the structure of the program. So the major modes for programming languages arrange for <TAB> to update the indentation of the current line. They also rebind <DEL> to treat a tab as if it were the equivalent number of spaces; this lets you delete one column of indentation without worrying whether the whitespace consists of spaces or tabs. Use C-b C-d to delete a tab character before point, in these modes.

Separate manuals are available for the modes for Ada (voir (ada-mode)Top section `Ada Mode' dans Ada Mode), C/C++/Objective C/Java/Corba IDL/Pike/AWK (voir (ccmode)Top section `CC Mode' dans CC Mode) and the IDLWAVE modes (voir (idlwave)Top section `IDLWAVE' dans IDLWAVE User Manual). For Fortran mode, see Fortran Mode.

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 adding ‘-hook’. For example, turning on C mode runs the hook c-mode-hook, while turning on Lisp mode runs the hook lisp-mode-hook. The purpose of the mode hook is to give you a place to set up customizations for that major mode. Voir la section Hooks.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.