aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2001-06-20 10:57:04 +0000
committerRichard M. Stallman2001-06-20 10:57:04 +0000
commitcf1c48d4ff55d4c643802f7fd0a0f3efb07a02d5 (patch)
treef68d6831e04ac4606c4ae9989697ae89774441d8
parentf25eb4f7390bbf6923e101b8dafec4e2a3f5a28a (diff)
downloademacs-cf1c48d4ff55d4c643802f7fd0a0f3efb07a02d5.tar.gz
emacs-cf1c48d4ff55d4c643802f7fd0a0f3efb07a02d5.zip
New node Program Misc; text about word and paragraph and selective
display features moved there. Major rewrite of Programming Modes node. Mention font lock and compilation commands in initial list of capabilities. Rewrite explanation of C-M- convention. In Basic Indent, add intro text.
-rw-r--r--man/programs.texi183
1 files changed, 95 insertions, 88 deletions
diff --git a/man/programs.texi b/man/programs.texi
index 2154f8b6c8b..218b1dcacf1 100644
--- a/man/programs.texi
+++ b/man/programs.texi
@@ -7,15 +7,15 @@
7@cindex C editing 7@cindex C editing
8@cindex program editing 8@cindex program editing
9 9
10 Emacs has many commands designed to understand the syntax of programming 10 Emacs provides many features to facilitate editing programs. These
11languages such as Lisp and C. These commands can: 11features can:
12 12
13@itemize @bullet 13@itemize @bullet
14@item 14@item
15Move over or kill balanced expressions or @dfn{sexps} (@pxref{Lists}). 15Move over or kill balanced expressions (@pxref{Lists}).
16@item 16@item
17Move over or mark top-level expressions---@dfn{defuns}, in Lisp; 17Move over or mark top-level expressions, such as @dfn{defuns} in
18functions, in C (@pxref{Defuns}). 18Lisp, or function definitions in C (@pxref{Defuns}).
19@item 19@item
20Show how parentheses balance (@pxref{Matching}). 20Show how parentheses balance (@pxref{Matching}).
21@item 21@item
@@ -23,30 +23,14 @@ Insert, kill or align comments (@pxref{Comments}).
23@item 23@item
24Follow the usual indentation conventions of the language 24Follow the usual indentation conventions of the language
25(@pxref{Program Indent}). 25(@pxref{Program Indent}).
26@item
27Highlight program syntax (@pxref{Font Lock}).
28@item
29Compile and debug programs (@pxref{Building}).
26@end itemize 30@end itemize
27 31
28 Emacs commands that operate on words, sentences and paragraphs are
29very useful in editing code even though their canonical application is
30for editing human language text. Most symbols contain words
31(@pxref{Words}); sentences can be found in strings and comments
32(@pxref{Sentences}). Paragraphs per se don't exist in code, but the
33paragraph commands are useful anyway, because programming language major
34modes define paragraphs to begin and end at blank lines
35(@pxref{Paragraphs}). Judicious use of blank lines to make the program
36clearer will also provide useful chunks of text for the paragraph
37commands to work on.
38
39 The selective display feature is useful for looking at the overall
40structure of a function (@pxref{Selective Display}). This feature
41hides the lines that are indented more than a specified amount.
42Programming modes often support Outline minor mode (@pxref{Outline
43Mode}). The Foldout package provides folding-editor features
44(@pxref{Foldout}).
45
46 The ``automatic typing'' features may be useful for writing programs.
47@xref{Top,,Autotyping, autotype, Autotyping}.
48
49@menu 32@menu
33* Misc for Programs:: Other Emacs features useful for editing programs.
50* Program Modes:: Major modes for editing programs. 34* Program Modes:: Major modes for editing programs.
51* Lists:: Expressions with balanced parentheses. 35* Lists:: Expressions with balanced parentheses.
52* List Commands:: The commands for working with list and sexps. 36* List Commands:: The commands for working with list and sexps.
@@ -73,10 +57,51 @@ Mode}). The Foldout package provides folding-editor features
73* Asm Mode:: Asm mode and its special features. 57* Asm Mode:: Asm mode and its special features.
74@end menu 58@end menu
75 59
60@node Misc for Programs
61@section Other Features Useful for Editing Programs
62
63 A number of Emacs commands that aren't designed specifically for
64editing programs are useful for it nonetheless.
65
66 The Emacs commands that operate on words, sentences and paragraphs
67are useful for editing code. Most symbols names contain words
68(@pxref{Words}); sentences can be found in strings and comments
69(@pxref{Sentences}). Paragraphs in the strict sense may be found in
70program code (in long comments), but the paragraph commands are useful
71in other places too, because programming language major modes define
72paragraphs to begin and end at blank lines (@pxref{Paragraphs}).
73Judicious use of blank lines to make the program clearer will also
74provide useful chunks of text for the paragraph commands to work on.
75
76 The selective display feature is useful for looking at the overall
77structure of a function (@pxref{Selective Display}). This feature
78hides the lines that are indented more than a specified amount.
79Programming modes often support Outline minor mode (@pxref{Outline
80Mode}). The Foldout package provides folding-editor features
81(@pxref{Foldout}).
82
83 The ``automatic typing'' features may be useful for writing programs.
84@xref{Top,,Autotyping, autotype, Autotyping}.
85
76@node Program Modes 86@node Program Modes
77@section Major Modes for Programming Languages 87@section Major Modes for Programming Languages
78
79@cindex modes for programming languages 88@cindex modes for programming languages
89
90 Emacs has specialized major modes for various programming languages.
91@xref{Major Modes}. A programming language major mode typically
92specifies the syntax of expressions, the customary rules for
93indentation, how to do syntax highlighting for the language, and how
94to find the beginning of a function definition. They often provide
95facilities for compiling and debugging programs as well.
96
97 Ideally, Emacs should provide a major mode for each programming
98language that you might want to edit; if it doesn't have a mode for
99your favorite language, you can contribute one. But often the mode
100for one language can serve for other syntactically similar languages.
101The major mode for language @var{l} is called @code{@var{l}-mode},
102and you can enable it by typing @kbd{M-x @var{l}-mode @key{RET}}.
103@xref{Choosing Modes}.
104
80@cindex Perl mode 105@cindex Perl mode
81@cindex Icon mode 106@cindex Icon mode
82@cindex Awk mode 107@cindex Awk mode
@@ -94,62 +119,36 @@ Mode}). The Foldout package provides folding-editor features
94@cindex Shell-script mode 119@cindex Shell-script mode
95@cindex Delphi mode 120@cindex Delphi mode
96@cindex PostScript mode 121@cindex PostScript mode
97 Emacs also has major modes for the programming languages Lisp, Scheme 122 The existing programming language major modes include Lisp, Scheme (a
98(a variant of Lisp) and the Scheme-based DSSSL expression language, Ada, 123variant of Lisp) and the Scheme-based DSSSL expression language, Ada,
99Awk, C, C++, Delphi (Object Pascal), Fortran (free and fixed format), 124Awk, C, C++, Delphi (Object Pascal), Fortran (free format and fixed
100Icon, IDLWAVE, 125format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s
101Java, Metafont (@TeX{}'s companion for font creation), Modula2, 126companion for font creation), Modula2, Objective-C, Octave, Pascal,
102Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Simula, 127Perl, Pike, PostScript, Prolog, Simula, and Tcl, and VHDL. There is
103VHDL, CORBA IDL, and Tcl. 128also a major mode for makefiles, called Makefile mode. An alternative
104There is also a major mode for makefiles, called Makefile 129mode for Perl is called CPerl mode. Modes are available for the
105mode. An alternative mode for Perl is called CPerl mode. Modes 130scripting languages of the common Unix shells, VMS DCL, and
106are available for scripts for the common Unix shells, VMS DCL and 131MS-DOS/MS-Windows @samp{BAT} files. There are also major modes for
107MS-DOS/MS-Windows @samp{BAT} files. In a similar fashion to programming 132editing various sorts of configuration files.
108languages, modes are provided for editing various sorts of configuration
109files.
110
111Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
112Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL
113(@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
114(@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}).
115
116 Ideally, a major mode should be implemented for each programming
117language that you might want to edit with Emacs; but often the mode for
118one language can serve for other syntactically similar languages. The
119language modes that exist are those that someone decided to take the
120trouble to write.
121
122 There are several forms of Lisp mode, which differ in the way they
123interface to Lisp execution. @xref{Executing Lisp}.
124
125 Major modes for programming languages usually provide conveniency
126features such as syntax-sensitive indentation, syntax highlighting
127(@pxref{Font Lock}), movement by blocks and functions, etc.
128
129 Each of the programming language major modes defines the @key{TAB} key
130to run an indentation function that knows the indentation conventions of
131that language and updates the current line's indentation accordingly.
132For example, in C mode @key{TAB} is bound to @code{c-indent-command}.
133@kbd{C-j} is normally defined to do @key{RET} followed by @key{TAB};
134thus, it too indents in a mode-specific fashion.
135 133
136@kindex DEL @r{(programming modes)} 134@kindex DEL @r{(programming modes)}
137@findex c-electric-backspace 135@findex c-electric-backspace
138 In most programming languages, indentation is likely to vary from 136 In most programming languages, indentation is likely to vary from
139line to line. So the major modes for those languages rebind @key{DEL} 137line to line. So the major modes for those languages rebind @key{DEL}
140to treat a tab as if it were the equivalent number of spaces (using 138to treat a tab as if it were the equivalent number of spaces. This
141the command @code{c-electric-backspace}). This makes it possible to 139makes it possible to reduce indentation one column at a time without
142rub out indentation one column at a time without worrying whether it 140worrying whether it is made up of spaces or tabs. Use @kbd{C-b C-d}
143is made up of spaces or tabs. Use @kbd{C-b C-d} to delete a tab 141to delete a tab character before point, in these modes.
144character before point, in these modes.
145 142
146 Programming language modes define paragraphs to be separated only by 143 Programming language modes define paragraphs to be separated only by
147blank lines, so that the paragraph commands remain useful. Auto Fill mode, 144blank lines, so that the paragraph commands remain useful. Auto Fill mode,
148if enabled in a programming language major mode, indents the new lines 145if enabled in a programming language major mode, indents the new lines
149which it creates. 146which it creates.
150 147
151 @xref{Choosing Modes}, for the description of how major modes are 148 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
152activated. 149Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL
150(@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
151(@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}).
153 152
154@cindex mode hook 153@cindex mode hook
155@vindex c-mode-hook 154@vindex c-mode-hook
@@ -169,13 +168,14 @@ adding @samp{-hook}. For example, turning on C mode runs the hook
169 168
170@cindex Control-Meta 169@cindex Control-Meta
171 By convention, Emacs keys for dealing with balanced expressions are 170 By convention, Emacs keys for dealing with balanced expressions are
172usually Control-Meta characters. They tend to be analogous in function 171Control-Meta characters. They act like the corresponding Control and
173to their Control and Meta equivalents. (For example, @kbd{C-M-b} moves 172Meta equivalents, except that they operate on balanced expressions
174back over one balanced expression, which is analogous to @kbd{C-b} that 173instead of on characters or words. For instance, the command
175moves one character back and to @kbd{M-b} which moves one word back.) 174@kbd{C-M-b} moves backward over a balanced expression, just as
176These commands are usually thought of as pertaining to expressions in 175@kbd{C-b} moves back over a character and @kbd{M-b} moves back over a
177programming languages, but can be useful with any language in which some 176word. These commands are intended for expressions in programming
178sort of parentheses exist (including human languages). 177languages, but can be useful for editing any text that has
178parentheses.
179 179
180@cindex list 180@cindex list
181@cindex sexp 181@cindex sexp
@@ -407,6 +407,11 @@ This program reformats a Lisp object with indentation chosen to look nice.
407@node Basic Indent 407@node Basic Indent
408@subsection Basic Program Indentation Commands 408@subsection Basic Program Indentation Commands
409 409
410 Programming language major modes define the @key{TAB} key to indent
411according to the usual conventions of the language you are editing.
412@kbd{C-j} is normally defined to do @key{RET} followed by @key{TAB};
413thus, it too indents in a mode-specific fashion.
414
410@c WideCommands 415@c WideCommands
411@table @kbd 416@table @kbd
412@item @key{TAB} 417@item @key{TAB}
@@ -420,23 +425,25 @@ Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}).
420@findex indent-line-function 425@findex indent-line-function
421 The basic indentation command is @key{TAB}, which gives the current line 426 The basic indentation command is @key{TAB}, which gives the current line
422the correct indentation as determined from the previous lines. The 427the correct indentation as determined from the previous lines. The
423function that @key{TAB} runs depends on the major mode; it is @code{indent-for-tab-command} 428function that @key{TAB} runs depends on the major mode; it is
429@code{indent-for-tab-command}
424in Lisp mode, @code{c-indent-command} in C mode, etc. These functions 430in Lisp mode, @code{c-indent-command} in C mode, etc. These functions
425understand different syntaxes for different languages, but they all do 431understand the syntax and conventions of different languages, but they all do
426about the same thing. @key{TAB} in any programming-language major mode 432conceptually the same job: @key{TAB} in any programming-language major mode
427inserts or deletes whitespace at the beginning of the current line, 433inserts or deletes whitespace at the beginning of the current line,
428independent of where point is in the line. If point is inside the 434independent of where point is in the line. If point was inside the
429whitespace at the beginning of the line, @key{TAB} leaves it at the end of 435whitespace at the beginning of the line, @key{TAB} puts it at the end of
430that whitespace; otherwise, @key{TAB} leaves point fixed with respect to 436that whitespace; otherwise, @key{TAB} keeps point fixed with respect to
431the characters around it. 437the characters around it.
432 438
433 Use @kbd{C-q @key{TAB}} to insert a tab at point. 439 Use @kbd{C-q @key{TAB}} to insert a tab at point.
434 440
435@kindex C-j 441@kindex C-j
436@findex newline-and-indent 442@findex newline-and-indent
437 When entering lines of new code, use @kbd{C-j} (@code{newline-and-indent}), 443 When entering lines of new code, use @kbd{C-j}
438which is equivalent to a @key{RET} followed by a @key{TAB}. @kbd{C-j} creates 444(@code{newline-and-indent}), which is equivalent to a @key{RET}
439a blank line and then gives it the appropriate indentation. 445followed by a @key{TAB}. @kbd{C-j} at the end of a line creates a
446blank line and then gives it the appropriate indentation.
440 447
441 @key{TAB} indents the second and following lines of the body of a 448 @key{TAB} indents the second and following lines of the body of a
442parenthetical grouping each under the preceding one; therefore, if you 449parenthetical grouping each under the preceding one; therefore, if you