Mercurial > emacs
annotate man/programs.texi @ 38123:af8117970ca7
More proofreading fixes from Peter Milliken.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Wed, 20 Jun 2001 09:48:52 +0000 |
parents | 4aeb215906f3 |
children | 278f2295cde6 |
rev | line source |
---|---|
25829 | 1 @c This is part of the Emacs manual. |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2 @c Copyright (C) 1985,86,87,93,94,95,97,99,2000 Free Software Foundation, Inc. |
25829 | 3 @c See file emacs.texi for copying conditions. |
4 @node Programs, Building, Text, Top | |
5 @chapter Editing Programs | |
6 @cindex Lisp editing | |
7 @cindex C editing | |
8 @cindex program editing | |
9 | |
10 Emacs has many commands designed to understand the syntax of programming | |
38051
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
11 languages such as Lisp and C. These commands can: |
25829 | 12 |
13 @itemize @bullet | |
14 @item | |
15 Move over or kill balanced expressions or @dfn{sexps} (@pxref{Lists}). | |
16 @item | |
17 Move over or mark top-level expressions---@dfn{defuns}, in Lisp; | |
18 functions, in C (@pxref{Defuns}). | |
19 @item | |
20 Show how parentheses balance (@pxref{Matching}). | |
21 @item | |
22 Insert, kill or align comments (@pxref{Comments}). | |
23 @item | |
24 Follow the usual indentation conventions of the language | |
25 (@pxref{Program Indent}). | |
26 @end itemize | |
27 | |
38051
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
28 Emacs commands that operate on words, sentences and paragraphs are |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
29 very useful in editing code even though their canonical application is |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
30 for editing human language text. Most symbols contain words |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
31 (@pxref{Words}); sentences can be found in strings and comments |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
32 (@pxref{Sentences}). Paragraphs per se don't exist in code, but the |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
33 paragraph commands are useful anyway, because programming language major |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
34 modes define paragraphs to begin and end at blank lines |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
35 (@pxref{Paragraphs}). Judicious use of blank lines to make the program |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
36 clearer will also provide useful chunks of text for the paragraph |
3382f3158d21
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38018
diff
changeset
|
37 commands to work on. |
25829 | 38 |
39 The selective display feature is useful for looking at the overall | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
40 structure of a function (@pxref{Selective Display}). This feature |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
41 hides the lines that are indented more than a specified amount. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
42 Programming modes often support Outline minor mode (@pxref{Outline |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
43 Mode}). The Foldout package provides folding-editor features |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
44 (@pxref{Foldout}). |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
45 |
36185 | 46 The ``automatic typing'' features may be useful for writing programs. |
37868
ac2238e335f8
Fix some xrefs to other manuals.
Richard M. Stallman <rms@gnu.org>
parents:
36786
diff
changeset
|
47 @xref{Top,,Autotyping, autotype, Autotyping}. |
25829 | 48 |
49 @menu | |
50 * Program Modes:: Major modes for editing programs. | |
51 * Lists:: Expressions with balanced parentheses. | |
52 * List Commands:: The commands for working with list and sexps. | |
53 * Defuns:: Each program is made up of separate functions. | |
54 There are editing commands to operate on them. | |
55 * Program Indent:: Adjusting indentation to show the nesting. | |
56 * Matching:: Insertion of a close-delimiter flashes matching open. | |
57 * Comments:: Inserting, killing, and aligning comments. | |
58 * Balanced Editing:: Inserting two matching parentheses at once, etc. | |
59 * Symbol Completion:: Completion on symbol names of your program or language. | |
60 * Which Function:: Which Function mode shows which function you are in. | |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
61 * Hideshow:: Displaying blocks selectively. |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
62 * Glasses:: Making identifiersLikeThis more readable. |
25829 | 63 * Documentation:: Getting documentation of functions you plan to call. |
64 * Change Log:: Maintaining a change history for your program. | |
30793 | 65 * Authors:: Maintaining an @file{AUTHORS} file. |
25829 | 66 * Tags:: Go direct to any function in your program in one |
67 command. Tags remembers which file it is in. | |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
68 * Imenu:: Making buffer indexes as menus. |
25829 | 69 * Emerge:: A convenient way of merging two versions of a program. |
26264 | 70 * C Modes:: Special commands of C, C++, Objective-C, |
25829 | 71 Java, and Pike modes. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
72 * Fortran:: Fortran mode and its special features. |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
73 * Asm Mode:: Asm mode and its special features. |
25829 | 74 @end menu |
75 | |
76 @node Program Modes | |
77 @section Major Modes for Programming Languages | |
78 | |
79 @cindex modes for programming languages | |
80 @cindex Perl mode | |
81 @cindex Icon mode | |
82 @cindex Awk mode | |
83 @cindex Makefile mode | |
84 @cindex Tcl mode | |
85 @cindex CPerl mode | |
26106 | 86 @cindex DSSSL mode |
87 @cindex Octave mode | |
88 @cindex Metafont mode | |
89 @cindex Modula2 mode | |
90 @cindex Prolog mode | |
91 @cindex Simula mode | |
92 @cindex VHDL mode | |
93 @cindex M4 mode | |
94 @cindex Shell-script mode | |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
95 @cindex Delphi mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
96 @cindex PostScript mode |
25829 | 97 Emacs also has major modes for the programming languages Lisp, Scheme |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
98 (a variant of Lisp) and the Scheme-based DSSSL expression language, Ada, |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
99 Awk, C, C++, Delphi (Object Pascal), Fortran (free and fixed format), |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
100 Icon, IDLWAVE, |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
101 Java, Metafont (@TeX{}'s companion for font creation), Modula2, |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
102 Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Simula, |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
103 VHDL, CORBA IDL, and Tcl. |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
104 There is also a major mode for makefiles, called Makefile |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
105 mode. An alternative mode for Perl is called CPerl mode. Modes |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
106 are available for scripts for the common Unix shells, VMS DCL and |
36185 | 107 MS-DOS/MS-Windows @samp{BAT} files. In a similar fashion to programming |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
108 languages, modes are provided for editing various sorts of configuration |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
109 files. |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
110 |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
111 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
112 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
113 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
114 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). |
25829 | 115 |
116 Ideally, a major mode should be implemented for each programming | |
117 language that you might want to edit with Emacs; but often the mode for | |
118 one language can serve for other syntactically similar languages. The | |
119 language modes that exist are those that someone decided to take the | |
120 trouble to write. | |
121 | |
122 There are several forms of Lisp mode, which differ in the way they | |
123 interface to Lisp execution. @xref{Executing Lisp}. | |
124 | |
38122
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
125 Major modes for programming languages usually provide conveniency |
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
126 features such as syntax-sensitive indentation, syntax highlighting |
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
127 (@pxref{Font Lock}), movement by blocks and functions, etc. |
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
128 |
25829 | 129 Each of the programming language major modes defines the @key{TAB} key |
130 to run an indentation function that knows the indentation conventions of | |
131 that language and updates the current line's indentation accordingly. | |
37978
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
132 For example, in C mode @key{TAB} is bound to @code{c-indent-command}. |
25829 | 133 @kbd{C-j} is normally defined to do @key{RET} followed by @key{TAB}; |
134 thus, it too indents in a mode-specific fashion. | |
135 | |
136 @kindex DEL @r{(programming modes)} | |
37978
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
137 @findex c-electric-backspace |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
138 In most programming languages, indentation is likely to vary from |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
139 line to line. So the major modes for those languages rebind @key{DEL} |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
140 to treat a tab as if it were the equivalent number of spaces (using |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
141 the command @code{c-electric-backspace}). This makes it possible to |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
142 rub out indentation one column at a time without worrying whether it |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
143 is made up of spaces or tabs. Use @kbd{C-b C-d} to delete a tab |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
144 character before point, in these modes. |
25829 | 145 |
146 Programming language modes define paragraphs to be separated only by | |
147 blank lines, so that the paragraph commands remain useful. Auto Fill mode, | |
148 if enabled in a programming language major mode, indents the new lines | |
149 which it creates. | |
150 | |
38122
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
151 @xref{Choosing Modes}, for the description of how major modes are |
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
152 activated. |
4aeb215906f3
Proofreading fixes from Peter Milliken <Peter.Milliken@GTECH.COM>.
Eli Zaretskii <eliz@gnu.org>
parents:
38090
diff
changeset
|
153 |
25829 | 154 @cindex mode hook |
155 @vindex c-mode-hook | |
156 @vindex lisp-mode-hook | |
157 @vindex emacs-lisp-mode-hook | |
158 @vindex lisp-interaction-mode-hook | |
159 @vindex scheme-mode-hook | |
160 Turning on a major mode runs a normal hook called the @dfn{mode hook}, | |
161 which is the value of a Lisp variable. Each major mode has a mode hook, | |
162 and the hook's name is always made from the mode command's name by | |
163 adding @samp{-hook}. For example, turning on C mode runs the hook | |
164 @code{c-mode-hook}, while turning on Lisp mode runs the hook | |
165 @code{lisp-mode-hook}. @xref{Hooks}. | |
166 | |
167 @node Lists | |
168 @section Lists and Sexps | |
169 | |
170 @cindex Control-Meta | |
171 By convention, Emacs keys for dealing with balanced expressions are | |
38123
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
172 usually Control-Meta characters. They tend to be analogous in function |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
173 to their Control and Meta equivalents. (For example, @kbd{C-M-b} moves |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
174 back over one balanced expression, which is analogous to @kbd{C-b} that |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
175 moves one character back and to @kbd{M-b} which moves one word back.) |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
176 These commands are usually thought of as pertaining to expressions in |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
177 programming languages, but can be useful with any language in which some |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
178 sort of parentheses exist (including human languages). |
25829 | 179 |
180 @cindex list | |
181 @cindex sexp | |
182 @cindex expression | |
183 These commands fall into two classes. Some deal only with @dfn{lists} | |
184 (parenthetical groupings). They see nothing except parentheses, brackets, | |
185 braces (whichever ones must balance in the language you are working with), | |
186 and escape characters that might be used to quote those. | |
187 | |
36185 | 188 The other commands deal with expressions or @dfn{sexps}. The word ``sexp'' |
25829 | 189 is derived from @dfn{s-expression}, the ancient term for an expression in |
36185 | 190 Lisp. But in Emacs, the notion of ``sexp'' is not limited to Lisp. It |
25829 | 191 refers to an expression in whatever language your program is written in. |
192 Each programming language has its own major mode, which customizes the | |
193 syntax tables so that expressions in that language count as sexps. | |
194 | |
195 Sexps typically include symbols, numbers, and string constants, as well | |
196 as anything contained in parentheses, brackets or braces. | |
197 | |
198 In languages that use prefix and infix operators, such as C, it is not | |
199 possible for all expressions to be sexps. For example, C mode does not | |
200 recognize @samp{foo + bar} as a sexp, even though it @emph{is} a C expression; | |
201 it recognizes @samp{foo} as one sexp and @samp{bar} as another, with the | |
202 @samp{+} as punctuation between them. This is a fundamental ambiguity: | |
203 both @samp{foo + bar} and @samp{foo} are legitimate choices for the sexp to | |
204 move over if point is at the @samp{f}. Note that @samp{(foo + bar)} is a | |
205 single sexp in C mode. | |
206 | |
207 Some languages have obscure forms of expression syntax that nobody | |
208 has bothered to make Emacs understand properly. | |
209 | |
210 @node List Commands | |
211 @section List And Sexp Commands | |
212 | |
213 @c doublewidecommands | |
214 @table @kbd | |
215 @item C-M-f | |
216 Move forward over a sexp (@code{forward-sexp}). | |
217 @item C-M-b | |
218 Move backward over a sexp (@code{backward-sexp}). | |
219 @item C-M-k | |
220 Kill sexp forward (@code{kill-sexp}). | |
221 @item C-M-@key{DEL} | |
222 Kill sexp backward (@code{backward-kill-sexp}). | |
223 @item C-M-u | |
224 Move up and backward in list structure (@code{backward-up-list}). | |
225 @item C-M-d | |
226 Move down and forward in list structure (@code{down-list}). | |
227 @item C-M-n | |
228 Move forward over a list (@code{forward-list}). | |
229 @item C-M-p | |
230 Move backward over a list (@code{backward-list}). | |
231 @item C-M-t | |
232 Transpose expressions (@code{transpose-sexps}). | |
233 @item C-M-@@ | |
234 Put mark after following expression (@code{mark-sexp}). | |
235 @end table | |
236 | |
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
237 @cindex parentheses, moving across |
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
238 @cindex matching parenthesis and braces, moving to |
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
239 @cindex braces, moving across |
25829 | 240 @kindex C-M-f |
241 @kindex C-M-b | |
242 @findex forward-sexp | |
243 @findex backward-sexp | |
244 To move forward over a sexp, use @kbd{C-M-f} (@code{forward-sexp}). If | |
245 the first significant character after point is an opening delimiter | |
246 (@samp{(} in Lisp; @samp{(}, @samp{[} or @samp{@{} in C), @kbd{C-M-f} | |
247 moves past the matching closing delimiter. If the character begins a | |
248 symbol, string, or number, @kbd{C-M-f} moves over that. | |
249 | |
250 The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a | |
251 sexp. The detailed rules are like those above for @kbd{C-M-f}, but with | |
252 directions reversed. If there are any prefix characters (single-quote, | |
253 backquote and comma, in Lisp) preceding the sexp, @kbd{C-M-b} moves back | |
254 over them as well. The sexp commands move across comments as if they | |
255 were whitespace in most modes. | |
256 | |
257 @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the | |
258 specified number of times; with a negative argument, it moves in the | |
259 opposite direction. | |
260 | |
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
261 @cindex deleting parenthesized expressions |
25829 | 262 @kindex C-M-k |
263 @findex kill-sexp | |
264 @kindex C-M-DEL | |
265 @findex backward-kill-sexp | |
266 Killing a whole sexp can be done with @kbd{C-M-k} (@code{kill-sexp}) | |
267 or @kbd{C-M-@key{DEL}} (@code{backward-kill-sexp}). @kbd{C-M-k} kills | |
268 the characters that @kbd{C-M-f} would move over, and @kbd{C-M-@key{DEL}} | |
269 kills the characters that @kbd{C-M-b} would move over. | |
270 | |
271 @kindex C-M-n | |
272 @kindex C-M-p | |
273 @findex forward-list | |
274 @findex backward-list | |
275 The @dfn{list commands} move over lists, as the sexp commands do, but skip | |
276 blithely over any number of other kinds of sexps (symbols, strings, etc.). | |
277 They are @kbd{C-M-n} (@code{forward-list}) and @kbd{C-M-p} | |
278 (@code{backward-list}). The main reason they are useful is that they | |
279 usually ignore comments (since the comments usually do not contain any | |
280 lists).@refill | |
281 | |
282 @kindex C-M-u | |
283 @kindex C-M-d | |
284 @findex backward-up-list | |
285 @findex down-list | |
286 @kbd{C-M-n} and @kbd{C-M-p} stay at the same level in parentheses, when | |
287 that's possible. To move @emph{up} one (or @var{n}) levels, use @kbd{C-M-u} | |
288 (@code{backward-up-list}). | |
289 @kbd{C-M-u} moves backward up past one unmatched opening delimiter. A | |
290 positive argument serves as a repeat count; a negative argument reverses | |
291 direction of motion and also requests repetition, so it moves forward and | |
292 up one or more levels.@refill | |
293 | |
294 To move @emph{down} in list structure, use @kbd{C-M-d} | |
295 (@code{down-list}). In Lisp mode, where @samp{(} is the only opening | |
296 delimiter, this is nearly the same as searching for a @samp{(}. An | |
297 argument specifies the number of levels of parentheses to go down. | |
298 | |
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
299 @cindex transposition of parenthesized expressions |
25829 | 300 @kindex C-M-t |
301 @findex transpose-sexps | |
302 A somewhat random-sounding command which is nevertheless handy is | |
303 @kbd{C-M-t} (@code{transpose-sexps}), which drags the previous sexp | |
304 across the next one. An argument serves as a repeat count, and a | |
305 negative argument drags backwards (thus canceling out the effect of | |
306 @kbd{C-M-t} with a positive argument). An argument of zero, rather than | |
307 doing nothing, transposes the sexps ending after point and the mark. | |
308 | |
309 @kindex C-M-@@ | |
310 @findex mark-sexp | |
311 To set the region around the next sexp in the buffer, use @kbd{C-M-@@} | |
312 (@code{mark-sexp}), which sets mark at the same place that @kbd{C-M-f} | |
313 would move to. @kbd{C-M-@@} takes arguments like @kbd{C-M-f}. In | |
314 particular, a negative argument is useful for putting the mark at the | |
315 beginning of the previous sexp. | |
316 | |
317 The list and sexp commands' understanding of syntax is completely | |
318 controlled by the syntax table. Any character can, for example, be | |
319 declared to be an opening delimiter and act like an open parenthesis. | |
320 @xref{Syntax}. | |
321 | |
322 @node Defuns | |
323 @section Defuns | |
324 @cindex defuns | |
325 | |
326 In Emacs, a parenthetical grouping at the top level in the buffer is | |
327 called a @dfn{defun}. The name derives from the fact that most top-level | |
328 lists in a Lisp file are instances of the special form @code{defun}, but | |
329 any top-level parenthetical grouping counts as a defun in Emacs parlance | |
330 regardless of what its contents are, and regardless of the programming | |
331 language in use. For example, in C, the body of a function definition is a | |
332 defun. | |
333 | |
38123
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
334 |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
335 @cindex move to beginning or end of function |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
336 @cindex function, move to beginning or end |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
337 @kindex C-M-a |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
338 @kindex C-M-e |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
339 @kindex C-M-h |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
340 @findex beginning-of-defun |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
341 @findex end-of-defun |
af8117970ca7
More proofreading fixes from Peter Milliken.
Eli Zaretskii <eliz@gnu.org>
parents:
38122
diff
changeset
|
342 @findex mark-defun |
25829 | 343 @c doublewidecommands |
344 @table @kbd | |
345 @item C-M-a | |
346 Move to beginning of current or preceding defun | |
347 (@code{beginning-of-defun}). | |
348 @item C-M-e | |
349 Move to end of current or following defun (@code{end-of-defun}). | |
350 @item C-M-h | |
351 Put region around whole current or following defun (@code{mark-defun}). | |
352 @end table | |
353 | |
36263
11db0318031d
Remove redundant index entries.
Eli Zaretskii <eliz@gnu.org>
parents:
36198
diff
changeset
|
354 @kindex C-M-h @r{(C mode)} |
25829 | 355 @findex c-mark-function |
356 If you wish to operate on the current defun, use @kbd{C-M-h} | |
357 (@code{mark-defun}) which puts point at the beginning and mark at the end | |
358 of the current or next defun. For example, this is the easiest way to get | |
359 ready to move the defun to a different place in the text. In C mode, | |
360 @kbd{C-M-h} runs the function @code{c-mark-function}, which is almost the | |
361 same as @code{mark-defun}; the difference is that it backs up over the | |
362 argument declarations, function name and returned data type so that the | |
363 entire C function is inside the region. @xref{Marking Objects}. | |
364 | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
365 @cindex open-parenthesis in leftmost column |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
366 @cindex ( in leftmost column |
25829 | 367 Emacs assumes that any open-parenthesis found in the leftmost column |
368 is the start of a defun. Therefore, @strong{never put an | |
369 open-parenthesis at the left margin in a Lisp file unless it is the | |
370 start of a top-level list. Never put an open-brace or other opening | |
371 delimiter at the beginning of a line of C code unless it starts the body | |
372 of a function.} The most likely problem case is when you want an | |
373 opening delimiter at the start of a line inside a string. To avoid | |
374 trouble, put an escape character (@samp{\}, in C and Emacs Lisp, | |
375 @samp{/} in some other Lisp dialects) before the opening delimiter. It | |
376 will not affect the contents of the string. | |
377 | |
378 In the remotest past, the original Emacs found defuns by moving upward a | |
379 level of parentheses until there were no more levels to go up. This always | |
380 required scanning all the way back to the beginning of the buffer, even for | |
381 a small function. To speed up the operation, Emacs was changed to assume | |
382 that any @samp{(} (or other character assigned the syntactic class of | |
383 opening-delimiter) at the left margin is the start of a defun. This | |
384 heuristic is nearly always right and avoids the costly scan; however, | |
385 it mandates the convention described above. | |
386 | |
387 @node Program Indent | |
388 @section Indentation for Programs | |
389 @cindex indentation for programs | |
390 | |
391 The best way to keep a program properly indented is to use Emacs to | |
392 reindent it as you change it. Emacs has commands to indent properly | |
393 either a single line, a specified number of lines, or all of the lines | |
394 inside a single parenthetical grouping. | |
395 | |
396 @menu | |
397 * Basic Indent:: Indenting a single line. | |
398 * Multi-line Indent:: Commands to reindent many lines at once. | |
399 * Lisp Indent:: Specifying how each Lisp function should be indented. | |
400 * C Indent:: Extra features for indenting C and related modes. | |
401 * Custom C Indent:: Controlling indentation style for C and related modes. | |
402 @end menu | |
403 | |
404 Emacs also provides a Lisp pretty-printer in the library @code{pp}. | |
405 This program reformats a Lisp object with indentation chosen to look nice. | |
406 | |
407 @node Basic Indent | |
408 @subsection Basic Program Indentation Commands | |
409 | |
410 @c WideCommands | |
411 @table @kbd | |
412 @item @key{TAB} | |
413 Adjust indentation of current line. | |
414 @item C-j | |
415 Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}). | |
416 @end table | |
417 | |
418 @kindex TAB @r{(programming modes)} | |
37978
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
419 @findex c-indent-command |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
420 @findex indent-line-function |
25829 | 421 The basic indentation command is @key{TAB}, which gives the current line |
422 the correct indentation as determined from the previous lines. The | |
37978
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
423 function that @key{TAB} runs depends on the major mode; it is @code{indent-for-tab-command} |
c41356c953a0
Correct names of some C mode indentation commands.
Richard M. Stallman <rms@gnu.org>
parents:
37868
diff
changeset
|
424 in Lisp mode, @code{c-indent-command} in C mode, etc. These functions |
25829 | 425 understand different syntaxes for different languages, but they all do |
426 about the same thing. @key{TAB} in any programming-language major mode | |
427 inserts or deletes whitespace at the beginning of the current line, | |
428 independent of where point is in the line. If point is inside the | |
429 whitespace at the beginning of the line, @key{TAB} leaves it at the end of | |
430 that whitespace; otherwise, @key{TAB} leaves point fixed with respect to | |
431 the characters around it. | |
432 | |
433 Use @kbd{C-q @key{TAB}} to insert a tab at point. | |
434 | |
435 @kindex C-j | |
436 @findex newline-and-indent | |
437 When entering lines of new code, use @kbd{C-j} (@code{newline-and-indent}), | |
438 which is equivalent to a @key{RET} followed by a @key{TAB}. @kbd{C-j} creates | |
439 a blank line and then gives it the appropriate indentation. | |
440 | |
441 @key{TAB} indents the second and following lines of the body of a | |
442 parenthetical grouping each under the preceding one; therefore, if you | |
443 alter one line's indentation to be nonstandard, the lines below will | |
444 tend to follow it. This behavior is convenient in cases where you have | |
445 overridden the standard result of @key{TAB} because you find it | |
446 unaesthetic for a particular line. | |
447 | |
448 Remember that an open-parenthesis, open-brace or other opening delimiter | |
449 at the left margin is assumed by Emacs (including the indentation routines) | |
450 to be the start of a function. Therefore, you must never have an opening | |
451 delimiter in column zero that is not the beginning of a function, not even | |
452 inside a string. This restriction is vital for making the indentation | |
453 commands fast; you must simply accept it. @xref{Defuns}, for more | |
454 information on this. | |
455 | |
38009
b6036155d1ca
(Basic Indent): Add a cross-reference to description of indent-tabs-mode.
Eli Zaretskii <eliz@gnu.org>
parents:
37997
diff
changeset
|
456 Normally, lines are indented with tabs and spaces. If you want Emacs |
b6036155d1ca
(Basic Indent): Add a cross-reference to description of indent-tabs-mode.
Eli Zaretskii <eliz@gnu.org>
parents:
37997
diff
changeset
|
457 to use spaces only, see @ref{Just Spaces}. |
b6036155d1ca
(Basic Indent): Add a cross-reference to description of indent-tabs-mode.
Eli Zaretskii <eliz@gnu.org>
parents:
37997
diff
changeset
|
458 |
25829 | 459 @node Multi-line Indent |
460 @subsection Indenting Several Lines | |
461 | |
462 When you wish to reindent several lines of code which have been altered | |
463 or moved to a different level in the list structure, you have several | |
464 commands available. | |
465 | |
466 @table @kbd | |
467 @item C-M-q | |
468 Reindent all the lines within one list (@code{indent-sexp}). | |
469 @item C-u @key{TAB} | |
470 Shift an entire list rigidly sideways so that its first line | |
471 is properly indented. | |
472 @item C-M-\ | |
473 Reindent all lines in the region (@code{indent-region}). | |
474 @end table | |
475 | |
476 @kindex C-M-q | |
477 @findex indent-sexp | |
478 You can reindent the contents of a single list by positioning point | |
479 before the beginning of it and typing @kbd{C-M-q} (@code{indent-sexp} in | |
480 Lisp mode, @code{c-indent-exp} in C mode; also bound to other suitable | |
481 commands in other modes). The indentation of the line the sexp starts on | |
482 is not changed; therefore, only the relative indentation within the list, | |
483 and not its position, is changed. To correct the position as well, type a | |
484 @key{TAB} before the @kbd{C-M-q}. | |
485 | |
486 @kindex C-u TAB | |
487 If the relative indentation within a list is correct but the | |
488 indentation of its first line is not, go to that line and type @kbd{C-u | |
489 @key{TAB}}. @key{TAB} with a numeric argument reindents the current | |
490 line as usual, then reindents by the same amount all the lines in the | |
491 grouping starting on the current line. In other words, it reindents the | |
492 whole grouping rigidly as a unit. It is clever, though, and does not | |
493 alter lines that start inside strings, or C preprocessor lines when in C | |
494 mode. | |
495 | |
496 Another way to specify the range to be reindented is with the region. | |
497 The command @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to | |
498 every line whose first character is between point and mark. | |
499 | |
500 @node Lisp Indent | |
501 @subsection Customizing Lisp Indentation | |
502 @cindex customizing Lisp indentation | |
503 | |
504 The indentation pattern for a Lisp expression can depend on the function | |
505 called by the expression. For each Lisp function, you can choose among | |
506 several predefined patterns of indentation, or define an arbitrary one with | |
507 a Lisp program. | |
508 | |
509 The standard pattern of indentation is as follows: the second line of the | |
510 expression is indented under the first argument, if that is on the same | |
511 line as the beginning of the expression; otherwise, the second line is | |
512 indented underneath the function name. Each following line is indented | |
513 under the previous line whose nesting depth is the same. | |
514 | |
515 @vindex lisp-indent-offset | |
516 If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides | |
517 the usual indentation pattern for the second line of an expression, so that | |
518 such lines are always indented @code{lisp-indent-offset} more columns than | |
519 the containing list. | |
520 | |
521 @vindex lisp-body-indent | |
522 The standard pattern is overridden for certain functions. Functions | |
523 whose names start with @code{def} always indent the second line by | |
524 @code{lisp-body-indent} extra columns beyond the open-parenthesis | |
525 starting the expression. | |
526 | |
527 The standard pattern can be overridden in various ways for individual | |
528 functions, according to the @code{lisp-indent-function} property of the | |
529 function name. There are four possibilities for this property: | |
530 | |
531 @table @asis | |
532 @item @code{nil} | |
533 This is the same as no property; the standard indentation pattern is used. | |
534 @item @code{defun} | |
535 The pattern used for function names that start with @code{def} is used for | |
536 this function also. | |
537 @item a number, @var{number} | |
538 The first @var{number} arguments of the function are | |
539 @dfn{distinguished} arguments; the rest are considered the @dfn{body} | |
540 of the expression. A line in the expression is indented according to | |
541 whether the first argument on it is distinguished or not. If the | |
542 argument is part of the body, the line is indented @code{lisp-body-indent} | |
543 more columns than the open-parenthesis starting the containing | |
544 expression. If the argument is distinguished and is either the first | |
545 or second argument, it is indented @emph{twice} that many extra columns. | |
546 If the argument is distinguished and not the first or second argument, | |
547 the standard pattern is followed for that line. | |
548 @item a symbol, @var{symbol} | |
549 @var{symbol} should be a function name; that function is called to | |
550 calculate the indentation of a line within this expression. The | |
551 function receives two arguments: | |
552 @table @asis | |
553 @item @var{state} | |
554 The value returned by @code{parse-partial-sexp} (a Lisp primitive for | |
555 indentation and nesting computation) when it parses up to the | |
556 beginning of this line. | |
557 @item @var{pos} | |
558 The position at which the line being indented begins. | |
559 @end table | |
560 @noindent | |
561 It should return either a number, which is the number of columns of | |
562 indentation for that line, or a list whose car is such a number. The | |
563 difference between returning a number and returning a list is that a | |
564 number says that all following lines at the same nesting level should | |
565 be indented just like this one; a list says that following lines might | |
566 call for different indentations. This makes a difference when the | |
567 indentation is being computed by @kbd{C-M-q}; if the value is a | |
568 number, @kbd{C-M-q} need not recalculate indentation for the following | |
569 lines until the end of the list. | |
570 @end table | |
571 | |
572 @node C Indent | |
573 @subsection Commands for C Indentation | |
574 | |
575 Here are the commands for indentation in C mode and related modes: | |
576 | |
577 @table @code | |
578 @item C-c C-q | |
579 @kindex C-c C-q @r{(C mode)} | |
580 @findex c-indent-defun | |
581 Reindent the current top-level function definition or aggregate type | |
582 declaration (@code{c-indent-defun}). | |
583 | |
584 @item C-M-q | |
585 @kindex C-M-q @r{(C mode)} | |
586 @findex c-indent-exp | |
587 Reindent each line in the balanced expression that follows point | |
588 (@code{c-indent-exp}). A prefix argument inhibits error checking and | |
589 warning messages about invalid syntax. | |
590 | |
591 @item @key{TAB} | |
592 @findex c-indent-command | |
593 Reindent the current line, and/or in some cases insert a tab character | |
594 (@code{c-indent-command}). | |
595 | |
596 If @code{c-tab-always-indent} is @code{t}, this command always reindents | |
597 the current line and does nothing else. This is the default. | |
598 | |
599 If that variable is @code{nil}, this command reindents the current line | |
600 only if point is at the left margin or in the line's indentation; | |
601 otherwise, it inserts a tab (or the equivalent number of spaces, | |
602 if @code{indent-tabs-mode} is @code{nil}). | |
603 | |
604 Any other value (not @code{nil} or @code{t}) means always reindent the | |
605 line, and also insert a tab if within a comment, a string, or a | |
606 preprocessor directive. | |
607 | |
608 @item C-u @key{TAB} | |
609 Reindent the current line according to its syntax; also rigidly reindent | |
610 any other lines of the expression that starts on the current line. | |
611 @xref{Multi-line Indent}. | |
612 @end table | |
613 | |
614 To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This | |
615 first selects the whole buffer as the region, then reindents that | |
616 region. | |
617 | |
618 To reindent the current block, use @kbd{C-M-u C-M-q}. This moves | |
619 to the front of the block and then reindents it all. | |
620 | |
621 @node Custom C Indent | |
622 @subsection Customizing C Indentation | |
623 | |
624 C mode and related modes use a simple yet flexible mechanism for | |
625 customizing indentation. The mechanism works in two steps: first it | |
626 classifies the line syntactically according to its contents and context; | |
627 second, it associates each kind of syntactic construct with an | |
628 indentation offset which you can customize. | |
629 | |
630 @menu | |
631 * Syntactic Analysis:: | |
632 * Indentation Calculation:: | |
633 * Changing Indent Style:: | |
634 * Syntactic Symbols:: | |
635 * Variables for C Indent:: | |
636 * C Indent Styles:: | |
637 @end menu | |
638 | |
639 @node Syntactic Analysis | |
640 @subsubsection Step 1---Syntactic Analysis | |
641 @cindex syntactic analysis | |
642 | |
643 In the first step, the C indentation mechanism looks at the line | |
644 before the one you are currently indenting and determines the syntactic | |
645 components of the construct on that line. It builds a list of these | |
646 syntactic components, each of which contains a @dfn{syntactic symbol} | |
647 and sometimes also a buffer position. Some syntactic symbols describe | |
648 grammatical elements, for example @code{statement} and | |
649 @code{substatement}; others describe locations amidst grammatical | |
650 elements, for example @code{class-open} and @code{knr-argdecl}. | |
651 | |
652 Conceptually, a line of C code is always indented relative to the | |
653 indentation of some line higher up in the buffer. This is represented | |
654 by the buffer positions in the syntactic component list. | |
655 | |
656 Here is an example. Suppose we have the following code in a C++ mode | |
657 buffer (the line numbers don't actually appear in the buffer): | |
658 | |
659 @example | |
660 1: void swap (int& a, int& b) | |
661 2: @{ | |
662 3: int tmp = a; | |
663 4: a = b; | |
664 5: b = tmp; | |
665 6: @} | |
666 @end example | |
667 | |
668 If you type @kbd{C-c C-s} (which runs the command | |
669 @code{c-show-syntactic-information}) on line 4, it shows the result of | |
670 the indentation mechanism for that line: | |
671 | |
672 @example | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
673 syntactic analysis: ((statement . 32)) |
25829 | 674 @end example |
675 | |
676 This indicates that the line is a statement and it is indented | |
677 relative to buffer position 32, which happens to be the @samp{i} in | |
678 @code{int} on line 3. If you move the cursor to line 3 and type | |
679 @kbd{C-c C-s}, it displays this: | |
680 | |
681 @example | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
682 syntactic analysis: ((defun-block-intro . 28)) |
25829 | 683 @end example |
684 | |
685 This indicates that the @code{int} line is the first statement in a | |
686 block, and is indented relative to buffer position 28, which is the | |
687 brace just after the function header. | |
688 | |
689 @noindent | |
690 Here is another example: | |
691 | |
692 @example | |
693 1: int add (int val, int incr, int doit) | |
694 2: @{ | |
695 3: if (doit) | |
696 4: @{ | |
697 5: return (val + incr); | |
698 6: @} | |
699 7: return (val); | |
700 8: @} | |
701 @end example | |
702 | |
703 @noindent | |
704 Typing @kbd{C-c C-s} on line 4 displays this: | |
705 | |
706 @example | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
707 syntactic analysis: ((substatement-open . 43)) |
25829 | 708 @end example |
709 | |
710 This says that the brace @emph{opens} a substatement block. By the | |
711 way, a @dfn{substatement} indicates the line after an @code{if}, | |
712 @code{else}, @code{while}, @code{do}, @code{switch}, @code{for}, | |
713 @code{try}, @code{catch}, @code{finally}, or @code{synchronized} | |
714 statement. | |
715 | |
716 @cindex syntactic component | |
717 @cindex syntactic symbol | |
718 @vindex c-syntactic-context | |
719 Within the C indentation commands, after a line has been analyzed | |
720 syntactically for indentation, the variable @code{c-syntactic-context} | |
721 contains a list that describes the results. Each element in this list | |
722 is a @dfn{syntactic component}: a cons cell containing a syntactic | |
723 symbol and (optionally) its corresponding buffer position. There may be | |
724 several elements in a component list; typically only one element has a | |
725 buffer position. | |
726 | |
727 @node Indentation Calculation | |
728 @subsubsection Step 2---Indentation Calculation | |
729 @cindex Indentation Calculation | |
730 | |
731 The C indentation mechanism calculates the indentation for the current | |
732 line using the list of syntactic components, @code{c-syntactic-context}, | |
733 derived from syntactic analysis. Each component is a cons cell that | |
734 contains a syntactic symbol and may also contain a buffer position. | |
735 | |
736 Each component contributes to the final total indentation of the line | |
737 in two ways. First, the syntactic symbol identifies an element of | |
738 @code{c-offsets-alist}, which is an association list mapping syntactic | |
739 symbols into indentation offsets. Each syntactic symbol's offset adds | |
740 to the total indentation. Second, if the component includes a buffer | |
741 position, the column number of that position adds to the indentation. | |
742 All these offsets and column numbers, added together, give the total | |
743 indentation. | |
744 | |
745 The following examples demonstrate the workings of the C indentation | |
746 mechanism: | |
747 | |
748 @example | |
749 1: void swap (int& a, int& b) | |
750 2: @{ | |
751 3: int tmp = a; | |
752 4: a = b; | |
753 5: b = tmp; | |
754 6: @} | |
755 @end example | |
756 | |
757 Suppose that point is on line 3 and you type @key{TAB} to reindent the | |
758 line. As explained above (@pxref{Syntactic Analysis}), the syntactic | |
759 component list for that line is: | |
760 | |
761 @example | |
762 ((defun-block-intro . 28)) | |
763 @end example | |
764 | |
765 In this case, the indentation calculation first looks up | |
766 @code{defun-block-intro} in the @code{c-offsets-alist} alist. Suppose | |
767 that it finds the integer 2; it adds this to the running total | |
768 (initialized to zero), yielding a updated total indentation of 2 spaces. | |
769 | |
770 The next step is to find the column number of buffer position 28. | |
771 Since the brace at buffer position 28 is in column zero, this adds 0 to | |
772 the running total. Since this line has only one syntactic component, | |
773 the total indentation for the line is 2 spaces. | |
774 | |
775 @example | |
776 1: int add (int val, int incr, int doit) | |
777 2: @{ | |
778 3: if (doit) | |
779 4: @{ | |
780 5: return(val + incr); | |
781 6: @} | |
782 7: return(val); | |
783 8: @} | |
784 @end example | |
785 | |
786 If you type @key{TAB} on line 4, the same process is performed, but | |
787 with different data. The syntactic component list for this line is: | |
788 | |
789 @example | |
790 ((substatement-open . 43)) | |
791 @end example | |
792 | |
793 Here, the indentation calculation's first job is to look up the | |
794 symbol @code{substatement-open} in @code{c-offsets-alist}. Let's assume | |
795 that the offset for this symbol is 2. At this point the running total | |
796 is 2 (0 + 2 = 2). Then it adds the column number of buffer position 43, | |
797 which is the @samp{i} in @code{if} on line 3. This character is in | |
798 column 2 on that line. Adding this yields a total indentation of 4 | |
799 spaces. | |
800 | |
801 @vindex c-strict-syntax-p | |
802 If a syntactic symbol in the analysis of a line does not appear in | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
803 @code{c-offsets-alist}, it is ignored. |
25829 | 804 |
805 @node Changing Indent Style | |
806 @subsubsection Changing Indentation Style | |
807 | |
808 There are two ways to customize the indentation style for the C-like | |
809 modes. First, you can select one of several predefined styles, each of | |
810 which specifies offsets for all the syntactic symbols. For more | |
811 flexibility, you can customize the handling of individual syntactic | |
812 symbols. @xref{Syntactic Symbols}, for a list of all defined syntactic | |
813 symbols. | |
814 | |
815 @table @kbd | |
816 @item M-x c-set-style @key{RET} @var{style} @key{RET} | |
817 Select predefined indentation style @var{style}. Type @kbd{?} when | |
818 entering @var{style} to see a list of supported styles; to find out what | |
819 a style looks like, select it and reindent some C code. | |
820 | |
821 @item C-c C-o @var{symbol} @key{RET} @var{offset} @key{RET} | |
822 Set the indentation offset for syntactic symbol @var{symbol} | |
823 (@code{c-set-offset}). The second argument @var{offset} specifies the | |
824 new indentation offset. | |
825 @end table | |
826 | |
827 The @code{c-offsets-alist} variable controls the amount of | |
828 indentation to give to each syntactic symbol. Its value is an | |
829 association list, and each element of the list has the form | |
830 @code{(@var{syntactic-symbol} . @var{offset})}. By changing the offsets | |
831 for various syntactic symbols, you can customize indentation in fine | |
832 detail. To change this alist, use @code{c-set-offset} (see below). | |
833 | |
834 Each offset value in @code{c-offsets-alist} can be an integer, a | |
835 function or variable name, a list, or one of the following symbols: @code{+}, | |
836 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}, indicating positive or negative | |
837 multiples of the variable @code{c-basic-offset}. Thus, if you want to | |
838 change the levels of indentation to be 3 spaces instead of 2 spaces, set | |
839 @code{c-basic-offset} to 3. | |
840 | |
841 Using a function as the offset value provides the ultimate flexibility | |
842 in customizing indentation. The function is called with a single | |
843 argument containing the @code{cons} of the syntactic symbol and | |
844 the buffer position, if any. The function should return an integer | |
845 offset. | |
26264 | 846 |
25829 | 847 If the offset value is a list, its elements are processed according |
848 to the rules above until a non-@code{nil} value is found. That value is | |
849 then added to the total indentation in the normal manner. The primary | |
850 use for this is to combine the results of several functions. | |
851 | |
852 @kindex C-c C-o @r{(C mode)} | |
853 @findex c-set-offset | |
854 The command @kbd{C-c C-o} (@code{c-set-offset}) is the easiest way to | |
855 set offsets, both interactively or in your @file{~/.emacs} file. First | |
856 specify the syntactic symbol, then the offset you want. @xref{Syntactic | |
857 Symbols}, for a list of valid syntactic symbols and their meanings. | |
858 | |
859 @node Syntactic Symbols | |
860 @subsubsection Syntactic Symbols | |
861 | |
862 Here is a table of valid syntactic symbols for indentation in C and | |
863 related modes, with their syntactic meanings. Normally, most of these | |
864 symbols are assigned offsets in @code{c-offsets-alist}. | |
865 | |
866 @table @code | |
867 @item string | |
868 Inside a multi-line string. | |
869 | |
870 @item c | |
871 Inside a multi-line C style block comment. | |
872 | |
873 @item defun-open | |
874 On a brace that opens a function definition. | |
875 | |
876 @item defun-close | |
877 On a brace that closes a function definition. | |
878 | |
879 @item defun-block-intro | |
880 In the first line in a top-level defun. | |
881 | |
882 @item class-open | |
883 On a brace that opens a class definition. | |
884 | |
885 @item class-close | |
886 On a brace that closes a class definition. | |
887 | |
888 @item inline-open | |
889 On a brace that opens an in-class inline method. | |
890 | |
891 @item inline-close | |
892 On a brace that closes an in-class inline method. | |
893 | |
894 @item extern-lang-open | |
895 On a brace that opens an external language block. | |
896 | |
897 @item extern-lang-close | |
898 On a brace that closes an external language block. | |
899 | |
900 @item func-decl-cont | |
901 The region between a function definition's argument list and the defun | |
902 opening brace (excluding K&R function definitions). In C, you cannot | |
903 put anything but whitespace and comments between them; in C++ and Java, | |
904 @code{throws} declarations and other things can appear in this context. | |
905 | |
906 @item knr-argdecl-intro | |
907 On the first line of a K&R C argument declaration. | |
908 | |
909 @item knr-argdecl | |
910 In one of the subsequent lines in a K&R C argument declaration. | |
911 | |
912 @item topmost-intro | |
913 On the first line in a topmost construct definition. | |
914 | |
915 @item topmost-intro-cont | |
916 On the topmost definition continuation lines. | |
917 | |
918 @item member-init-intro | |
919 On the first line in a member initialization list. | |
920 | |
921 @item member-init-cont | |
922 On one of the subsequent member initialization list lines. | |
923 | |
924 @item inher-intro | |
925 On the first line of a multiple inheritance list. | |
926 | |
927 @item inher-cont | |
928 On one of the subsequent multiple inheritance lines. | |
929 | |
930 @item block-open | |
931 On a statement block open brace. | |
932 | |
933 @item block-close | |
934 On a statement block close brace. | |
935 | |
936 @item brace-list-open | |
937 On the opening brace of an @code{enum} or @code{static} array list. | |
938 | |
939 @item brace-list-close | |
940 On the closing brace of an @code{enum} or @code{static} array list. | |
941 | |
942 @item brace-list-intro | |
943 On the first line in an @code{enum} or @code{static} array list. | |
944 | |
945 @item brace-list-entry | |
946 On one of the subsequent lines in an @code{enum} or @code{static} array | |
947 list. | |
948 | |
949 @item brace-entry-open | |
950 On one of the subsequent lines in an @code{enum} or @code{static} array | |
951 list, when the line begins with an open brace. | |
952 | |
953 @item statement | |
954 On an ordinary statement. | |
955 | |
956 @item statement-cont | |
957 On a continuation line of a statement. | |
958 | |
959 @item statement-block-intro | |
960 On the first line in a new statement block. | |
961 | |
962 @item statement-case-intro | |
963 On the first line in a @code{case} ``block.'' | |
964 | |
965 @item statement-case-open | |
966 On the first line in a @code{case} block starting with brace. | |
967 | |
968 @item inexpr-statement | |
969 On a statement block inside an expression. This is used for a GNU | |
970 extension to the C language, and for Pike special functions that take a | |
971 statement block as an argument. | |
972 | |
973 @item inexpr-class | |
974 On a class definition inside an expression. This is used for anonymous | |
975 classes and anonymous array initializers in Java. | |
976 | |
977 @item substatement | |
978 On the first line after an @code{if}, @code{while}, @code{for}, | |
979 @code{do}, or @code{else}. | |
980 | |
981 @item substatement-open | |
982 On the brace that opens a substatement block. | |
983 | |
984 @item case-label | |
985 On a @code{case} or @code{default} label. | |
986 | |
987 @item access-label | |
988 On a C++ @code{private}, @code{protected}, or @code{public} access label. | |
989 | |
990 @item label | |
991 On any ordinary label. | |
992 | |
993 @item do-while-closure | |
994 On the @code{while} that ends a @code{do}-@code{while} construct. | |
995 | |
996 @item else-clause | |
997 On the @code{else} of an @code{if}-@code{else} construct. | |
998 | |
999 @item catch-clause | |
1000 On the @code{catch} and @code{finally} lines in | |
1001 @code{try}@dots{}@code{catch} constructs in C++ and Java. | |
1002 | |
1003 @item comment-intro | |
1004 On a line containing only a comment introduction. | |
1005 | |
1006 @item arglist-intro | |
1007 On the first line in an argument list. | |
1008 | |
1009 @item arglist-cont | |
1010 On one of the subsequent argument list lines when no arguments follow on | |
1011 the same line as the arglist opening parenthesis. | |
1012 | |
1013 @item arglist-cont-nonempty | |
1014 On one of the subsequent argument list lines when at least one argument | |
1015 follows on the same line as the arglist opening parenthesis. | |
1016 | |
1017 @item arglist-close | |
1018 On the closing parenthesis of an argument list. | |
1019 | |
1020 @item stream-op | |
1021 On one of the lines continuing a stream operator construct. | |
1022 | |
1023 @item inclass | |
1024 On a construct that is nested inside a class definition. The | |
1025 indentation is relative to the open brace of the class definition. | |
1026 | |
1027 @item inextern-lang | |
1028 On a construct that is nested inside an external language block. | |
1029 | |
1030 @item inexpr-statement | |
1031 On the first line of statement block inside an expression. This is used | |
1032 for the GCC extension to C that uses the syntax @code{(@{ @dots{} @})}. | |
1033 It is also used for the special functions that takes a statement block | |
1034 as an argument in Pike. | |
1035 | |
1036 @item inexpr-class | |
1037 On the first line of a class definition inside an expression. This is | |
1038 used for anonymous classes and anonymous array initializers in Java. | |
1039 | |
1040 @item cpp-macro | |
1041 On the start of a cpp macro. | |
1042 | |
1043 @item friend | |
1044 On a C++ @code{friend} declaration. | |
1045 | |
1046 @item objc-method-intro | |
1047 On the first line of an Objective-C method definition. | |
1048 | |
1049 @item objc-method-args-cont | |
1050 On one of the lines continuing an Objective-C method definition. | |
1051 | |
1052 @item objc-method-call-cont | |
1053 On one of the lines continuing an Objective-C method call. | |
1054 | |
1055 @item inlambda | |
1056 Like @code{inclass}, but used inside lambda (i.e. anonymous) functions. Only | |
1057 used in Pike. | |
1058 | |
1059 @item lambda-intro-cont | |
1060 On a line continuing the header of a lambda function, between the | |
1061 @code{lambda} keyword and the function body. Only used in Pike. | |
1062 @end table | |
1063 | |
1064 @node Variables for C Indent | |
1065 @subsubsection Variables for C Indentation | |
1066 | |
1067 This section describes additional variables which control the | |
1068 indentation behavior of C mode and related mode. | |
1069 | |
1070 @table @code | |
1071 @item c-offsets-alist | |
1072 @vindex c-offsets-alist | |
1073 Association list of syntactic symbols and their indentation offsets. | |
1074 You should not set this directly, only with @code{c-set-offset}. | |
1075 @xref{Changing Indent Style}, for details. | |
1076 | |
1077 @item c-style-alist | |
1078 @vindex c-style-alist | |
1079 Variable for defining indentation styles; see below. | |
1080 | |
1081 @item c-basic-offset | |
1082 @vindex c-basic-offset | |
1083 Amount of basic offset used by @code{+} and @code{-} symbols in | |
26264 | 1084 @code{c-offsets-alist}.@refill |
25829 | 1085 |
1086 @item c-special-indent-hook | |
1087 @vindex c-special-indent-hook | |
1088 Hook for user-defined special indentation adjustments. This hook is | |
1089 called after a line is indented by C mode and related modes. | |
1090 @end table | |
1091 | |
1092 The variable @code{c-style-alist} specifies the predefined indentation | |
1093 styles. Each element has form @code{(@var{name} | |
1094 @var{variable-setting}@dots{})}, where @var{name} is the name of the | |
1095 style. Each @var{variable-setting} has the form @code{(@var{variable} | |
1096 . @var{value})}; @var{variable} is one of the customization variables | |
1097 used by C mode, and @var{value} is the value for that variable when | |
1098 using the selected style. | |
1099 | |
1100 When @var{variable} is @code{c-offsets-alist}, that is a special case: | |
1101 @var{value} is appended to the front of the value of @code{c-offsets-alist} | |
1102 instead of replacing that value outright. Therefore, it is not necessary | |
1103 for @var{value} to specify each and every syntactic symbol---only those | |
1104 for which the style differs from the default. | |
1105 | |
1106 The indentation of lines containing only comments is also affected by | |
1107 the variable @code{c-comment-only-line-offset} (@pxref{Comments in C}). | |
1108 | |
1109 @node C Indent Styles | |
1110 @subsubsection C Indentation Styles | |
1111 @cindex c indentation styles | |
1112 | |
1113 A @dfn{C style} is a collection of indentation style customizations. | |
1114 Emacs comes with several predefined indentation styles for C and related | |
1115 modes, including @code{gnu}, @code{k&r}, @code{bsd}, @code{stroustrup}, | |
1116 @code{linux}, @code{python}, @code{java}, @code{whitesmith}, | |
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1117 @code{ellemtel}, @code{cc-mode}, and @code{user}. |
25829 | 1118 |
1119 @findex c-set-style | |
1120 @vindex c-default-style | |
1121 To choose the style you want, use the command @kbd{M-x c-set-style}. | |
1122 Specify a style name as an argument (case is not significant in C style | |
1123 names). The chosen style only affects newly visited buffers, not those | |
1124 you are already editing. You can also set the variable | |
1125 @code{c-default-style} to specify the style for various major modes. | |
1126 Its value should be an alist, in which each element specifies one major | |
1127 mode and which indentation style to use for it. For example, | |
1128 | |
1129 @example | |
1130 (setq c-default-style | |
1131 '((java-mode . "java") (other . "gnu"))) | |
1132 @end example | |
1133 | |
1134 @noindent | |
1135 specifies an explicit choice for Java mode, and the default @samp{gnu} | |
1136 style for the other C-like modes. | |
1137 | |
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1138 The style @code{gnu} defines the formatting recommend by the GNU |
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1139 Project; it is the default, so as to encourage the indentation we |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1140 recommend. However, if you make changes in variables such as |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1141 @code{c-basic-offset} and @code{c-offsets-alist} in your |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1142 @file{~/.emacs} file, your changes override the what @code{gnu} style |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1143 says. |
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1144 |
25829 | 1145 @findex c-add-style |
1146 To define a new C indentation style, call the function | |
1147 @code{c-add-style}: | |
1148 | |
1149 @example | |
1150 (c-add-style @var{name} @var{values} @var{use-now}) | |
1151 @end example | |
1152 | |
1153 @noindent | |
1154 Here @var{name} is the name of the new style (a string), and | |
1155 @var{values} is an alist whose elements have the form | |
1156 @code{(@var{variable} . @var{value})}. The variables you specify should | |
1157 be among those documented in @ref{Variables for C Indent}. | |
1158 | |
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1159 If @var{use-now} is non-@code{nil}, @code{c-add-style} selects the new |
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1160 style after defining it. |
25829 | 1161 |
1162 @node Matching | |
1163 @section Automatic Display Of Matching Parentheses | |
1164 @cindex matching parentheses | |
1165 @cindex parentheses, displaying matches | |
1166 | |
1167 The Emacs parenthesis-matching feature is designed to show | |
1168 automatically how parentheses match in the text. Whenever you type a | |
1169 self-inserting character that is a closing delimiter, the cursor moves | |
1170 momentarily to the location of the matching opening delimiter, provided | |
1171 that is on the screen. If it is not on the screen, some text near it is | |
1172 displayed in the echo area. Either way, you can tell what grouping is | |
1173 being closed off. | |
1174 | |
1175 In Lisp, automatic matching applies only to parentheses. In C, it | |
1176 applies to braces and brackets too. Emacs knows which characters to regard | |
1177 as matching delimiters based on the syntax table, which is set by the major | |
1178 mode. @xref{Syntax}. | |
1179 | |
1180 If the opening delimiter and closing delimiter are mismatched---such as | |
1181 in @samp{[x)}---a warning message is displayed in the echo area. The | |
1182 correct matches are specified in the syntax table. | |
1183 | |
1184 @vindex blink-matching-paren | |
1185 @vindex blink-matching-paren-distance | |
1186 @vindex blink-matching-delay | |
1187 Three variables control parenthesis match display. | |
1188 @code{blink-matching-paren} turns the feature on or off; @code{nil} | |
1189 turns it off, but the default is @code{t} to turn match display on. | |
1190 @code{blink-matching-delay} says how many seconds to wait; the default | |
1191 is 1, but on some systems it is useful to specify a fraction of a | |
1192 second. @code{blink-matching-paren-distance} specifies how many | |
1193 characters back to search to find the matching opening delimiter. If | |
1194 the match is not found in that far, scanning stops, and nothing is | |
1195 displayed. This is to prevent scanning for the matching delimiter from | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1196 wasting lots of time when there is no match. The default is 25600. |
25829 | 1197 |
1198 @cindex Show Paren mode | |
34122
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1199 @cindex highlighting matching parentheses |
25829 | 1200 @findex show-paren-mode |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1201 Show Paren mode provides a more powerful kind of automatic |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1202 parenthesis matching. Whenever point is after a close parenthesis, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1203 the close parenthesis and its matching open parenthesis are both |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1204 highlighted; otherwise, if point is before an open parenthesis, the |
34122
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1205 matching close parenthesis is highlighted. (There is no need to |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1206 highlight the open parenthesis after point because the cursor appears |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1207 on top of that character.) Use the command @kbd{M-x show-paren-mode} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1208 to enable or disable this mode. |
34122
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1209 |
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1210 By default, @code{show-paren-mode} uses colors to highlight the |
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1211 parentheses. However, if your display doesn't support colors, you can |
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1212 customize the faces @code{show-paren-match-face} and |
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1213 @code{show-paren-mismatch-face} to use other attributes, such as bold or |
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1214 underline. @xref{Face Customization}. |
25829 | 1215 |
1216 @node Comments | |
1217 @section Manipulating Comments | |
1218 @cindex comments | |
1219 | |
1220 Because comments are such an important part of programming, Emacs | |
1221 provides special commands for editing and inserting comments. | |
1222 | |
1223 @menu | |
1224 * Comment Commands:: | |
1225 * Multi-Line Comments:: | |
1226 * Options for Comments:: | |
1227 @end menu | |
1228 | |
1229 @node Comment Commands | |
1230 @subsection Comment Commands | |
1231 @cindex indentation for comments | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1232 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1233 The comment commands in this table insert, kill and align comments. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1234 They are described in this section and following sections. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1235 |
25829 | 1236 @table @kbd |
1237 @item M-; | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1238 Insert or realign comment on current line; alternatively, comment or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1239 uncomment the region (@code{comment-dwim}). |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1240 @item C-u M-; |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1241 Kill comment on current line (@code{comment-kill}). |
25829 | 1242 @item C-x ; |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1243 Set comment column (@code{comment-set-column}). |
25829 | 1244 @item C-M-j |
1245 Like @key{RET} followed by inserting and aligning a comment | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1246 (@code{comment-indent-new-line}). |
25829 | 1247 @item M-x comment-region |
1248 Add or remove comment delimiters on all the lines in the region. | |
1249 @end table | |
1250 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1251 @kindex M-; |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1252 @findex comment-dwim |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1253 The command to create or align a comment is @kbd{M-;} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1254 (@code{comment-dwim}). The word ``dwim'' is an acronym for ``Do What |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1255 I Mean''; it indicates that this command can be used for many |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1256 different jobs relating to comments, depending on the situation where |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1257 you use it. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1258 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1259 If there is no comment already on the line, @kbd{M-;} inserts a new |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1260 comment, aligned at a specific column called the @dfn{comment column}. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1261 The new comment begins with the string Emacs thinks comments should |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1262 start with (the value of @code{comment-start}; see below). Point is |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1263 after that string, so you can insert the text of the comment right |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1264 away. If the major mode has specified a string to terminate comments, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1265 @kbd{M-;} inserts that too, to keep the syntax valid. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1266 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1267 If the text of the line extends past the comment column, then the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1268 comment start string is indented to a suitable boundary (usually, at |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1269 least one space is inserted). |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1270 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1271 You can also use @kbd{M-;} to align an existing comment. If a line |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1272 already contains the comment-start string, @kbd{M-;} reindents it to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1273 the conventional alignment and moves point after it. (Exception: |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1274 comments starting in column 0 are not moved.) Even when an existing |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1275 comment is properly aligned, @kbd{M-;} is still useful for moving |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1276 directly to the start of the text inside the comment. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1277 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1278 @findex comment-kill |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1279 @kindex C-u M-; |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1280 @kbd{C-u M-;} kills any comment on the current line, along with the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1281 whitespace before it. To reinsert the comment on another line, move |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1282 to the end of that line, do @kbd{C-y}, and then do @kbd{M-;} to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1283 realign it. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1284 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1285 Note that @kbd{C-u M-;} is not a distinct key; it is @kbd{M-;} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1286 (@code{comment-dwim}) with a prefix argument. That command is |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1287 programmed so that when it receives a prefix argument it calls |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1288 @code{comment-kill}. However, @code{comment-kill} is a valid command |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1289 in its own right, and you can bind it directly to a key if you wish. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1290 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1291 @kbd{M-;} does two other jobs when used with an active region in |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1292 Transient Mark mode (@pxref{Transient Mark}). Then it either adds or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1293 removes comment delimiters on each line of the region. (If every line |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1294 is a comment, it removes comment delimiters from each; otherwise, it |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1295 adds comment delimiters to each.) If you are not using Transient Mark |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1296 mode, then you should use the commands @code{comment-region} and |
36198 | 1297 @code{uncomment-region} to do these jobs (@pxref{Multi-Line Comments}). |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1298 A prefix argument used in these circumstances specifies how many |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1299 comment delimiters to add or how many to delete. |
25829 | 1300 |
1301 Some major modes have special rules for indenting certain kinds of | |
1302 comments in certain contexts. For example, in Lisp code, comments which | |
1303 start with two semicolons are indented as if they were lines of code, | |
1304 instead of at the comment column. Comments which start with three | |
1305 semicolons are supposed to start at the left margin. Emacs understands | |
1306 these conventions by indenting a double-semicolon comment using @key{TAB}, | |
1307 and by not changing the indentation of a triple-semicolon comment at all. | |
1308 | |
1309 @example | |
1310 ;; This function is just an example | |
1311 ;;; Here either two or three semicolons are appropriate. | |
1312 (defun foo (x) | |
1313 ;;; And now, the first part of the function: | |
1314 ;; The following line adds one. | |
1315 (1+ x)) ; This line adds one. | |
1316 @end example | |
1317 | |
1318 In C code, a comment preceded on its line by nothing but whitespace | |
1319 is indented like a line of code. | |
1320 | |
1321 @node Multi-Line Comments | |
1322 @subsection Multiple Lines of Comments | |
1323 | |
1324 @kindex C-M-j | |
1325 @cindex blank lines in programs | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1326 @findex comment-indent-new-line |
25829 | 1327 If you are typing a comment and wish to continue it on another line, |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1328 you can use the command @kbd{C-M-j} (@code{comment-indent-new-line}). |
25829 | 1329 This terminates the comment you are typing, creates a new blank line |
1330 afterward, and begins a new comment indented under the old one. When | |
1331 Auto Fill mode is on, going past the fill column while typing a comment | |
1332 causes the comment to be continued in just this fashion. If point is | |
1333 not at the end of the line when @kbd{C-M-j} is typed, the text on | |
1334 the rest of the line becomes part of the new comment line. | |
1335 | |
1336 @findex comment-region | |
1337 To turn existing lines into comment lines, use the @kbd{M-x | |
1338 comment-region} command. It adds comment delimiters to the lines that start | |
1339 in the region, thus commenting them out. With a negative argument, it | |
1340 does the opposite---it deletes comment delimiters from the lines in the | |
1341 region. | |
1342 | |
1343 With a positive argument, @code{comment-region} duplicates the last | |
1344 character of the comment start sequence it adds; the argument specifies | |
1345 how many copies of the character to insert. Thus, in Lisp mode, | |
1346 @kbd{C-u 2 M-x comment-region} adds @samp{;;} to each line. Duplicating | |
1347 the comment delimiter is a way of calling attention to the comment. It | |
1348 can also affect how the comment is indented. In Lisp, for proper | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1349 indentation, you should use an argument of two or three, if between defuns; |
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1350 if within a defun, it must be three. |
25829 | 1351 |
1352 @node Options for Comments | |
1353 @subsection Options Controlling Comments | |
1354 | |
1355 @vindex comment-column | |
1356 @kindex C-x ; | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1357 @findex comment-set-column |
25829 | 1358 The comment column is stored in the variable @code{comment-column}. You |
1359 can set it to a number explicitly. Alternatively, the command @kbd{C-x ;} | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1360 (@code{comment-set-column}) sets the comment column to the column point is |
25829 | 1361 at. @kbd{C-u C-x ;} sets the comment column to match the last comment |
1362 before point in the buffer, and then does a @kbd{M-;} to align the | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1363 current line's comment under the previous one. |
25829 | 1364 |
1365 The variable @code{comment-column} is per-buffer: setting the variable | |
1366 in the normal fashion affects only the current buffer, but there is a | |
1367 default value which you can change with @code{setq-default}. | |
1368 @xref{Locals}. Many major modes initialize this variable for the | |
1369 current buffer. | |
1370 | |
1371 @vindex comment-start-skip | |
1372 The comment commands recognize comments based on the regular | |
1373 expression that is the value of the variable @code{comment-start-skip}. | |
1374 Make sure this regexp does not match the null string. It may match more | |
1375 than the comment starting delimiter in the strictest sense of the word; | |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1376 for example, in C mode the value of the variable is |
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1377 @c This stops M-q from breaking the line inside that @code. |
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1378 @code{@w{"/\\*+ *\\|//+ *""}}, which matches extra stars and spaces |
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1379 after the @samp{/*} itself, and accepts C++ style comments also. |
25829 | 1380 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in |
1381 the string, which is needed to deny the first star its special meaning | |
1382 in regexp syntax. @xref{Regexps}.) | |
1383 | |
1384 @vindex comment-start | |
1385 @vindex comment-end | |
1386 When a comment command makes a new comment, it inserts the value of | |
1387 @code{comment-start} to begin it. The value of @code{comment-end} is | |
1388 inserted after point, so that it will follow the text that you will insert | |
1389 into the comment. In C mode, @code{comment-start} has the value | |
1390 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}. | |
1391 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1392 @vindex comment-padding |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1393 The variable @code{comment-padding} specifies how many spaces |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1394 @code{comment-region} should insert on each line between the |
38018
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1395 comment delimiter and the line's original text. The default is 1, |
f802bdff6c2c
Update various command names and variable defaults.
Richard M. Stallman <rms@gnu.org>
parents:
38009
diff
changeset
|
1396 to insert one space. |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1397 |
25829 | 1398 @vindex comment-multi-line |
1399 The variable @code{comment-multi-line} controls how @kbd{C-M-j} | |
1400 (@code{indent-new-comment-line}) behaves when used inside a comment. If | |
1401 @code{comment-multi-line} is @code{nil}, as it normally is, then the | |
1402 comment on the starting line is terminated and a new comment is started | |
1403 on the new following line. If @code{comment-multi-line} is not | |
1404 @code{nil}, then the new following line is set up as part of the same | |
1405 comment that was found on the starting line. This is done by not | |
1406 inserting a terminator on the old line, and not inserting a starter on | |
1407 the new line. In languages where multi-line comments work, the choice | |
1408 of value for this variable is a matter of taste. | |
1409 | |
1410 @vindex comment-indent-function | |
1411 The variable @code{comment-indent-function} should contain a function | |
1412 that will be called to compute the indentation for a newly inserted | |
1413 comment or for aligning an existing comment. It is set differently by | |
1414 various major modes. The function is called with no arguments, but with | |
1415 point at the beginning of the comment, or at the end of a line if a new | |
1416 comment is to be inserted. It should return the column in which the | |
1417 comment ought to start. For example, in Lisp mode, the indent hook | |
1418 function bases its decision on how many semicolons begin an existing | |
1419 comment, and on the code in the preceding lines. | |
1420 | |
1421 @node Balanced Editing | |
1422 @section Editing Without Unbalanced Parentheses | |
1423 | |
1424 @table @kbd | |
1425 @item M-( | |
1426 Put parentheses around next sexp(s) (@code{insert-parentheses}). | |
1427 @item M-) | |
1428 Move past next close parenthesis and reindent | |
1429 (@code{move-past-close-and-reindent}). | |
1430 @end table | |
1431 | |
1432 @kindex M-( | |
1433 @kindex M-) | |
1434 @findex insert-parentheses | |
1435 @findex move-past-close-and-reindent | |
1436 The commands @kbd{M-(} (@code{insert-parentheses}) and @kbd{M-)} | |
1437 (@code{move-past-close-and-reindent}) are designed to facilitate a style | |
1438 of editing which keeps parentheses balanced at all times. @kbd{M-(} | |
1439 inserts a pair of parentheses, either together as in @samp{()}, or, if | |
1440 given an argument, around the next several sexps. It leaves point after | |
1441 the open parenthesis. The command @kbd{M-)} moves past the close | |
1442 parenthesis, deleting any indentation preceding it, and indenting with | |
1443 @kbd{C-j} after it. | |
1444 | |
1445 For example, instead of typing @kbd{( F O O )}, you can type @kbd{M-( | |
1446 F O O}, which has the same effect except for leaving the cursor before | |
1447 the close parenthesis. | |
1448 | |
1449 @vindex parens-require-spaces | |
1450 @kbd{M-(} may insert a space before the open parenthesis, depending on | |
1451 the syntax class of the preceding character. Set | |
1452 @code{parens-require-spaces} to @code{nil} value if you wish to inhibit | |
1453 this. | |
1454 | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1455 @findex check-parens |
31035
64a11267ce9a
check-parens can also find unbalanced quotes in strings.
Eli Zaretskii <eliz@gnu.org>
parents:
31033
diff
changeset
|
1456 @cindex unbalanced parentheses and quotes |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1457 You can use @kbd{M-x check-parens} to find any unbalanced |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1458 parentheses and unbalanced string quotes in a buffer. |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1459 |
25829 | 1460 @node Symbol Completion |
1461 @section Completion for Symbol Names | |
1462 @cindex completion (symbol names) | |
1463 | |
1464 Usually completion happens in the minibuffer. But one kind of completion | |
1465 is available in all buffers: completion for symbol names. | |
1466 | |
1467 @kindex M-TAB | |
1468 The character @kbd{M-@key{TAB}} runs a command to complete the partial | |
1469 symbol before point against the set of meaningful symbol names. Any | |
1470 additional characters determined by the partial name are inserted at | |
1471 point. | |
1472 | |
1473 If the partial name in the buffer has more than one possible completion | |
1474 and they have no additional characters in common, a list of all possible | |
1475 completions is displayed in another window. | |
1476 | |
36263
11db0318031d
Remove redundant index entries.
Eli Zaretskii <eliz@gnu.org>
parents:
36198
diff
changeset
|
1477 @cindex tags-based completion |
25829 | 1478 @cindex Info index completion |
1479 @findex complete-symbol | |
1480 In most programming language major modes, @kbd{M-@key{TAB}} runs the | |
1481 command @code{complete-symbol}, which provides two kinds of completion. | |
1482 Normally it does completion based on a tags table (@pxref{Tags}); with a | |
1483 numeric argument (regardless of the value), it does completion based on | |
1484 the names listed in the Info file indexes for your language. Thus, to | |
1485 complete the name of a symbol defined in your own program, use | |
1486 @kbd{M-@key{TAB}} with no argument; to complete the name of a standard | |
1487 library function, use @kbd{C-u M-@key{TAB}}. Of course, Info-based | |
1488 completion works only if there is an Info file for the standard library | |
1489 functions of your language, and only if it is installed at your site. | |
1490 | |
1491 @cindex Lisp symbol completion | |
36263
11db0318031d
Remove redundant index entries.
Eli Zaretskii <eliz@gnu.org>
parents:
36198
diff
changeset
|
1492 @cindex completion (Lisp symbols) |
25829 | 1493 @findex lisp-complete-symbol |
1494 In Emacs-Lisp mode, the name space for completion normally consists of | |
1495 nontrivial symbols present in Emacs---those that have function | |
1496 definitions, values or properties. However, if there is an | |
1497 open-parenthesis immediately before the beginning of the partial symbol, | |
1498 only symbols with function definitions are considered as completions. | |
1499 The command which implements this is @code{lisp-complete-symbol}. | |
1500 | |
1501 In Text mode and related modes, @kbd{M-@key{TAB}} completes words | |
1502 based on the spell-checker's dictionary. @xref{Spelling}. | |
1503 | |
1504 @node Which Function | |
1505 @section Which Function Mode | |
1506 | |
1507 Which Function mode is a minor mode that displays the current function | |
1508 name in the mode line, as you move around in a buffer. | |
1509 | |
1510 @findex which-function-mode | |
1511 @vindex which-func-modes | |
1512 To enable (or disable) Which Function mode, use the command @kbd{M-x | |
1513 which-function-mode}. This command is global; it applies to all | |
1514 buffers, both existing ones and those yet to be created. However, this | |
1515 only affects certain major modes, those listed in the value of | |
1516 @code{which-func-modes}. (If the value is @code{t}, then Which Function | |
1517 mode applies to all major modes that know how to support it---which are | |
1518 the major modes that support Imenu.) | |
1519 | |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1520 @node Hideshow |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1521 @section Hideshow minor mode |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1522 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1523 @findex hs-minor-mode |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1524 Hideshow minor mode provides selective display of portions of a |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1525 file, known as @dfn{blocks}. You can use @kbd{M-x hs-minor-mode} to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1526 enable or disable this mode, or add @code{hs-minor-mode} to the mode |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1527 hook for certain major modes in order to enable it automatically for |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1528 those modes. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1529 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1530 Just what constitutes a block depends on the major mode. In C mode |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1531 or C++ mode, they are delimited by braces, while in Lisp mode and |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1532 similar modes they are delimited by parentheses. Multi-line comments |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1533 also count as blocks. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1534 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1535 @findex hs-hide-all |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1536 @findex hs-hide-block |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1537 @findex hs-show-all |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1538 @findex hs-show-block |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1539 @findex hs-show-region |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1540 @findex hs-hide-level |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1541 @findex hs-minor-mode |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1542 @kindex C-c @@ C-h |
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1543 @kindex C-c @@ C-s |
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1544 @kindex C-c @@ C-M-h |
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1545 @kindex C-c @@ C-M-s |
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1546 @kindex C-c @@ C-r |
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1547 @kindex C-c @@ C-l |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1548 @kindex S-Mouse-2 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1549 @table @kbd |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1550 @item C-c @@ C-h |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1551 Hide the current block (@code{hs-hide-block}). |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1552 @item C-c @@ C-s |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1553 Show the current block (@code{hs-show-block}). |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1554 @item C-c @@ C-c |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1555 Either hide or show the current block (@code{hs-toggle-hiding}) |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1556 @item S-Mouse-2 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1557 Either hide or show the block you click on (@code{hs-mouse-toggle-hiding}) |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1558 @item C-c @@ C-M-h |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1559 Hide all top-level blocks (@code{hs-hide-all}). |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1560 @item C-c @@ C-M-s |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1561 Show everything in the buffer (@code{hs-show-all}). |
37997
c329103798cc
(Hideshow): Fix the docs of keybindings which used a single `@'.
Eli Zaretskii <eliz@gnu.org>
parents:
37978
diff
changeset
|
1562 @item C-c @@ C-l |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1563 Hide all blocks @var{n} levels below this block |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1564 (@code{hs-hide-level}). |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1565 @end table |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1566 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1567 @vindex hs-hide-comments-when-hiding-all |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1568 @vindex hs-isearch-open |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1569 @vindex hs-special-modes-alist |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1570 These user options exist for customizing Hideshow mode. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1571 |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1572 @table @code |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1573 @item hs-hide-comments-when-hiding-all |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1574 Non-@code{nil} says that @kbd{hs-hide-all} should hide comments too. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1575 @item hs-isearch-open |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1576 Specifies what kind of hidden blocks to open in Isearch mode. |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1577 @item hs-special-modes-alist |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1578 Specifies |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1579 Initializes Hideshow variables for different modes. |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1580 @end table |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1581 |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1582 @node Glasses |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1583 @section Glasses minor mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1584 @cindex Glasses mode |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1585 @cindex identifiers, making long ones readable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1586 @cindex StudlyCaps, making them readable |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1587 @findex glasses-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1588 |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1589 Glasses minor mode makes @samp{unreadableIdentifiersLikeThis} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1590 readable by altering the display. It can do this in two different |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1591 ways: by displaying underscores between an lower-case letter and the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1592 following capital letter, or by emboldening the capital letters. It |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1593 does not alter the buffer text, only the way they display, so you can |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1594 use it even on read-only buffers. You can use the command @kbd{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1595 glasses-mode} to enable or disable the mode; you can also add |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1596 @code{glasses-mode} to the mode hook of appropriate programming |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1597 language major modes. |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1598 |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1599 @node Documentation |
25829 | 1600 @section Documentation Commands |
1601 | |
1602 As you edit Lisp code to be run in Emacs, the commands @kbd{C-h f} | |
1603 (@code{describe-function}) and @kbd{C-h v} (@code{describe-variable}) can | |
1604 be used to print documentation of functions and variables that you want to | |
1605 call. These commands use the minibuffer to read the name of a function or | |
1606 variable to document, and display the documentation in a window. | |
1607 | |
1608 For extra convenience, these commands provide default arguments based on | |
1609 the code in the neighborhood of point. @kbd{C-h f} sets the default to the | |
1610 function called in the innermost list containing point. @kbd{C-h v} uses | |
1611 the symbol name around or adjacent to point as its default. | |
1612 | |
1613 @cindex Eldoc mode | |
1614 @findex eldoc-mode | |
1615 For Emacs Lisp code, you can also use Eldoc mode. This minor mode | |
1616 constantly displays in the echo area the argument list for the function | |
1617 being called at point. (In other words, it finds the function call that | |
1618 point is contained in, and displays the argument list of that function.) | |
1619 Eldoc mode applies in Emacs Lisp and Lisp Interaction modes only. Use | |
1620 the command @kbd{M-x eldoc-mode} to enable or disable this feature. | |
1621 | |
1622 @findex info-lookup-symbol | |
1623 @findex info-lookup-file | |
1624 @kindex C-h C-i | |
1625 For C, Lisp, and other languages, you can use @kbd{C-h C-i} | |
1626 (@code{info-lookup-symbol}) to view the Info documentation for a symbol. | |
1627 You specify the symbol with the minibuffer; by default, it uses the | |
1628 symbol that appears in the buffer at point. The major mode determines | |
1629 where to look for documentation for the symbol---which Info files and | |
1630 which indices. You can also use @kbd{M-x info-lookup-file} to look for | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1631 documentation for a file name. Currently this supports the following |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1632 modes: Awk, Autoconf, Bison, C, Emacs Lisp, LaTeX, M4, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1633 Makefile, Octave, Perl, Scheme and Texinfo, provided you have installed |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1634 the relevant Info files, which are typically available with the appropriate GNU |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1635 package. |
25829 | 1636 |
1637 @findex manual-entry | |
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1638 @cindex manual pages |
25829 | 1639 You can read the ``man page'' for an operating system command, library |
1640 function, or system call, with the @kbd{M-x manual-entry} command. It | |
1641 runs the @code{man} program to format the man page, and runs it | |
1642 asynchronously if your system permits, so that you can keep on editing | |
1643 while the page is being formatted. (MS-DOS and MS-Windows 3 do not | |
1644 permit asynchronous subprocesses, so on these systems you cannot edit | |
1645 while Emacs waits for @code{man} to exit.) The result goes in a buffer | |
1646 named @samp{*Man @var{topic}*}. These buffers use a special major mode, | |
1647 Man mode, that facilitates scrolling and examining other manual pages. | |
1648 For details, type @kbd{C-h m} while in a man page buffer. | |
1649 | |
29840
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1650 @cindex sections of manual pages |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1651 Man pages are classified into @dfn{sections}; sometimes there are |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1652 man pages with the same name in different sections. To read a man |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1653 page from a specific section, type @samp{@var{topic}(@var{section})} or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1654 @samp{@var{section} @var{topic}} when @kbd{M-x manual-entry} prompts |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1655 for the topic. For example, to read the man page for the C library |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1656 function @code{chmod} (as opposed to a command by the same name), type |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1657 @kbd{M-x manual-entry @key{RET} chmod(2v) @key{RET}} (assuming |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1658 @code{chmod} is in section @samp{2v}). |
29840
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1659 |
29854
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1660 If you do not specify a section, the results depend on how the |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1661 @code{man} command works on your system. Some of them display only |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1662 the first man page they find. Others display all man pages that have |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1663 the specified name, so you can page between them with the @kbd{M-n} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1664 and @kbd{M-p} keys. The mode line shows how many manual pages are |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1665 available in the Man buffer. |
29854
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1666 |
25829 | 1667 @vindex Man-fontify-manpage-flag |
1668 For a long man page, setting the faces properly can take substantial | |
1669 time. By default, Emacs uses faces in man pages if Emacs can display | |
1670 different fonts or colors. You can turn off use of faces in man pages | |
1671 by setting the variable @code{Man-fontify-manpage-flag} to @code{nil}. | |
1672 | |
1673 @findex Man-fontify-manpage | |
1674 If you insert the text of a man page into an Emacs buffer in some | |
1675 other fashion, you can use the command @kbd{M-x Man-fontify-manpage} to | |
1676 perform the same conversions that @kbd{M-x manual-entry} does. | |
1677 | |
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1678 @findex woman |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1679 @cindex manual pages, on MS-DOS/MS-Windows |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1680 An alternative way of reading manual pages is the @kbd{M-x woman} |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1681 command@footnote{The name of the command, @code{woman}, is an acronym |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1682 for ``w/o (without) man,'' since it doesn't use the @code{man} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1683 program.}. Unlike @kbd{M-x man}, it does not run any external |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1684 programs to format and display the man pages; instead it does the job |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1685 in Emacs Lisp, so it works on systems such as MS-Windows, where the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1686 @code{man} program and other the programs it needs are not readily |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1687 available. @kbd{M-x woman} prompts for a name of a manual page, and |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1688 provides completion based on the list of manual pages that are |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1689 installed on your machine; the list of available manual pages is |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1690 computed automatically the first time you invoke @code{woman}. The |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1691 word at point in the current buffer is used to suggest the default |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1692 name of the manual page. |
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1693 |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1694 With a numeric argument, @kbd{M-x woman} recomputes the list of the |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1695 manual pages used for completion. This is useful if you add or delete |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1696 manual pages. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1697 |
29840
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1698 If you type a name of a manual page and @kbd{M-x woman} finds that |
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1699 several manual pages by the same name exist in different sections, it |
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1700 pops up a window with possible candidates asking you to choose one of |
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1701 them. |
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1702 |
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1703 @vindex woman-manpath |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1704 By default, @kbd{M-x woman} looks up the manual pages in directories |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1705 listed by the @code{MANPATH} environment variable. (If @code{MANPATH} |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1706 is not set, @code{woman} uses a suitable default value, which can be |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1707 customized.) More precisely, @code{woman} looks for subdirectories that |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1708 match the shell wildcard @file{man*} in each one of these directories, |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1709 and tries to find the manual pages in those subdirectories. When first |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1710 invoked, @kbd{M-x woman} converts the value of @code{MANPATH} to a list |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1711 of directory names and stores that list in the @code{woman-manpath} |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1712 variable. By changing the value of this variable, you can customize the |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1713 list of directories where @code{woman} looks for manual pages. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1714 |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1715 @vindex woman-path |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1716 In addition, you can augment the list of directories searched by |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1717 @code{woman} by setting the value of the @code{woman-path} variable. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1718 This variable should hold a list of specific directories which |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1719 @code{woman} should search, in addition to those in |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1720 @code{woman-manpath}. Unlike @code{woman-manpath}, the directories in |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1721 @code{woman-path} are searched for the manual pages, not for @file{man*} |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1722 subdirectories. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1723 |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1724 @findex woman-find-file |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1725 Occasionally, you might need to display manual pages that are not in |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1726 any of the directories listed by @code{woman-manpath} and |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1727 @code{woman-path}. The @kbd{M-x woman-find-file} command prompts for a |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1728 name of a manual page file, with completion, and then formats and |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1729 displays that file like @kbd{M-x woman} does. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1730 |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1731 @vindex woman-dired-keys |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1732 First time you invoke @kbd{M-x woman}, it defines the Dired @kbd{W} |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1733 key to run the @code{woman-find-file} command on the current line's |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1734 file. You can disable this by setting the variable |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1735 @code{woman-dired-keys} to @code{nil}. @xref{Dired}. In addition, the |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1736 Tar-mode @kbd{w} key is bound to @code{woman-find-file} on the current |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1737 line's archive member. |
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1738 |
30668
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1739 For more information about setting up and using @kbd{M-x woman}, see |
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1740 @ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The WoMan |
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1741 Manual}. |
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1742 |
25829 | 1743 Eventually the GNU project hopes to replace most man pages with |
1744 better-organized manuals that you can browse with Info. @xref{Misc | |
1745 Help}. Since this process is only partially completed, it is still | |
1746 useful to read manual pages. | |
1747 | |
1748 @node Change Log | |
1749 @section Change Logs | |
1750 | |
1751 @cindex change log | |
1752 @kindex C-x 4 a | |
1753 @findex add-change-log-entry-other-window | |
1754 The Emacs command @kbd{C-x 4 a} adds a new entry to the change log | |
1755 file for the file you are editing | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1756 (@code{add-change-log-entry-other-window}). If that file is actually |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1757 a backup file, it makes an entry appropriate for the file's |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1758 parent---that is useful for making log entries for functions that |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1759 have been deleted in the current version. |
25829 | 1760 |
1761 A change log file contains a chronological record of when and why you | |
1762 have changed a program, consisting of a sequence of entries describing | |
1763 individual changes. Normally it is kept in a file called | |
1764 @file{ChangeLog} in the same directory as the file you are editing, or | |
1765 one of its parent directories. A single @file{ChangeLog} file can | |
1766 record changes for all the files in its directory and all its | |
1767 subdirectories. | |
1768 | |
1769 A change log entry starts with a header line that contains your name, | |
1770 your email address (taken from the variable @code{user-mail-address}), | |
1771 and the current date and time. Aside from these header lines, every | |
1772 line in the change log starts with a space or a tab. The bulk of the | |
1773 entry consists of @dfn{items}, each of which starts with a line starting | |
1774 with whitespace and a star. Here are two entries, both dated in May | |
1775 1993, each with two items: | |
1776 | |
1777 @iftex | |
1778 @medbreak | |
1779 @end iftex | |
1780 @smallexample | |
1781 1993-05-25 Richard Stallman <rms@@gnu.org> | |
1782 | |
1783 * man.el: Rename symbols `man-*' to `Man-*'. | |
1784 (manual-entry): Make prompt string clearer. | |
1785 | |
1786 * simple.el (blink-matching-paren-distance): | |
1787 Change default to 12,000. | |
1788 | |
1789 1993-05-24 Richard Stallman <rms@@gnu.org> | |
1790 | |
1791 * vc.el (minor-mode-map-alist): Don't use it if it's void. | |
1792 (vc-cancel-version): Doc fix. | |
1793 @end smallexample | |
1794 | |
1795 One entry can describe several changes; each change should have its | |
1796 own item. Normally there should be a blank line between items. When | |
1797 items are related (parts of the same change, in different places), group | |
1798 them by leaving no blank line between them. The second entry above | |
1799 contains two items grouped in this way. | |
1800 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1801 @kbd{C-x 4 a} visits the change log file and creates a new entry |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1802 unless the most recent entry is for today's date and your name. It |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1803 also creates a new item for the current file. For many languages, it |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1804 can even guess the name of the function or other object that was |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1805 changed. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1806 |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1807 @vindex add-log-keep-changes-together |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1808 When the option @code{add-log-keep-changes-together} is |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1809 non-@code{nil}, @kbd{C-x 4 a} adds to any existing entry for the file |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1810 rather than starting a new entry. |
25829 | 1811 |
31052
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1812 @vindex change-log-version-info-enabled |
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1813 @vindex change-log-version-number-regexp-list |
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1814 @cindex file version in change log entries |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1815 If the value of the variable @code{change-log-version-info-enabled} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1816 is non-@code{nil}, @kbd{C-x 4 a} ads the file's version number to the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1817 change log entry. It finds the version number by searching the first |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1818 ten percent of the file, using regular expressions from the variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1819 @code{change-log-version-number-regexp-list}. |
31052
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1820 |
25829 | 1821 @cindex Change Log mode |
1822 @findex change-log-mode | |
1823 The change log file is visited in Change Log mode. In this major | |
1824 mode, each bunch of grouped items counts as one paragraph, and each | |
1825 entry is considered a page. This facilitates editing the entries. | |
1826 @kbd{C-j} and auto-fill indent each new line like the previous line; | |
1827 this is convenient for entering the contents of an entry. | |
1828 | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1829 @findex change-log-merge |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1830 You can use the command @kbd{M-x change-log-merge} to merge other |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1831 log files into a buffer in Change Log Mode, preserving the date |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1832 ordering of entries. |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1833 |
30850
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1834 @findex change-log-redate |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1835 @cindex converting change log date style |
30968
2dfd4d6a9043
Remove redundant description of change-log-redate.
Eli Zaretskii <eliz@gnu.org>
parents:
30850
diff
changeset
|
1836 Versions of Emacs before 20.1 used a different format for the time of |
2dfd4d6a9043
Remove redundant description of change-log-redate.
Eli Zaretskii <eliz@gnu.org>
parents:
30850
diff
changeset
|
1837 the change log entry: |
30850
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1838 |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1839 @smallexample |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1840 Fri May 25 11:23:23 1993 Richard Stallman <rms@@gnu.org> |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1841 @end smallexample |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1842 |
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1843 @noindent |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1844 The @kbd{M-x change-log-redate} command converts all the old-style |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1845 date entries in the change log file visited in the current buffer to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1846 the new format, to make the file uniform in style. This is handy when |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1847 entries are contributed by many different people, some of whom use old |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1848 versions of Emacs. |
30850
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1849 |
25829 | 1850 Version control systems are another way to keep track of changes in your |
1851 program and keep a change log. @xref{Log Buffer}. | |
1852 | |
30793 | 1853 @node Authors |
1854 @section @file{AUTHORS} files | |
1855 @cindex @file{AUTHORS} file | |
1856 | |
1857 Programs which have many contributors usually include a file named | |
1858 @file{AUTHORS} in their distribution, which lists the individual | |
1859 contributions. Emacs has a special command for maintaining the | |
1860 @file{AUTHORS} file that is part of the Emacs distribution. | |
1861 | |
1862 @findex authors | |
1863 The @kbd{M-x authors} command prompts for the name of the root of the | |
1864 Emacs source directory. It then scans @file{ChageLog} files and Lisp | |
1865 source files under that directory for information about authors of | |
1866 individual packages and people who made changes in source files, and | |
1867 puts the information it gleans into a buffer named @samp{*Authors*}. | |
1868 You can then edit the contents of that buffer and merge it with the | |
1869 exisiting @file{AUTHORS} file. | |
1870 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1871 Do not assume that this command finds all the contributors; don't |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1872 assume that a person not listed in the output was not a contributor. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1873 If you merged in someone's contribution and did not put his name |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1874 in the change log, he won't show up in @kbd{M-x authors} either. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1875 |
25829 | 1876 @node Tags |
1877 @section Tags Tables | |
1878 @cindex tags table | |
1879 | |
1880 A @dfn{tags table} is a description of how a multi-file program is | |
1881 broken up into files. It lists the names of the component files and the | |
1882 names and positions of the functions (or other named subunits) in each | |
1883 file. Grouping the related files makes it possible to search or replace | |
1884 through all the files with one command. Recording the function names | |
1885 and positions makes possible the @kbd{M-.} command which finds the | |
1886 definition of a function by looking up which of the files it is in. | |
1887 | |
1888 Tags tables are stored in files called @dfn{tags table files}. The | |
1889 conventional name for a tags table file is @file{TAGS}. | |
1890 | |
1891 Each entry in the tags table records the name of one tag, the name of the | |
1892 file that the tag is defined in (implicitly), and the position in that file | |
1893 of the tag's definition. | |
1894 | |
1895 Just what names from the described files are recorded in the tags table | |
1896 depends on the programming language of the described file. They | |
36737
71af0a08c2cc
Mention that file names are tags.
Francesco Potortì <pot@gnu.org>
parents:
36263
diff
changeset
|
1897 normally include all file names, functions and subroutines, and may |
71af0a08c2cc
Mention that file names are tags.
Francesco Potortì <pot@gnu.org>
parents:
36263
diff
changeset
|
1898 also include global variables, data types, and anything else |
71af0a08c2cc
Mention that file names are tags.
Francesco Potortì <pot@gnu.org>
parents:
36263
diff
changeset
|
1899 convenient. Each name recorded is called a @dfn{tag}. |
25829 | 1900 |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1901 @cindex C++ class browser, tags |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1902 @cindex tags, C++ |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1903 @cindex class browser, C++ |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1904 @cindex Ebrowse |
37868
ac2238e335f8
Fix some xrefs to other manuals.
Richard M. Stallman <rms@gnu.org>
parents:
36786
diff
changeset
|
1905 See also the Ebrowse facility, which is tailored for C++. |
ac2238e335f8
Fix some xrefs to other manuals.
Richard M. Stallman <rms@gnu.org>
parents:
36786
diff
changeset
|
1906 @xref{Top,, Ebrowse, ebrowse, Ebrowse User's Manual}. |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1907 |
25829 | 1908 @menu |
26264 | 1909 * Tag Syntax:: Tag syntax for various types of code and text files. |
25829 | 1910 * Create Tags Table:: Creating a tags table with @code{etags}. |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
1911 * Etags Regexps:: Create arbitrary tags using regular expressions. |
25829 | 1912 * Select Tags Table:: How to visit a tags table. |
26264 | 1913 * Find Tag:: Commands to find the definition of a specific tag. |
25829 | 1914 * Tags Search:: Using a tags table for searching and replacing. |
1915 * List Tags:: Listing and finding tags defined in a file. | |
1916 @end menu | |
1917 | |
1918 @node Tag Syntax | |
1919 @subsection Source File Tag Syntax | |
1920 | |
1921 Here is how tag syntax is defined for the most popular languages: | |
1922 | |
1923 @itemize @bullet | |
1924 @item | |
1925 In C code, any C function or typedef is a tag, and so are definitions of | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1926 @code{struct}, @code{union} and @code{enum}. |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1927 @code{#define} macro definitions and @code{enum} constants are also |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1928 tags, unless you specify @samp{--no-defines} when making the tags table. |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1929 Similarly, global variables are tags, unless you specify |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1930 @samp{--no-globals}. Use of @samp{--no-globals} and @samp{--no-defines} |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1931 can make the tags table file much smaller. |
25829 | 1932 |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1933 You can tag function declarations and external variables in addition |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1934 to function definitions by giving the @samp{--declarations} option to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1935 @code{etags}. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1936 |
25829 | 1937 @item |
1938 In C++ code, in addition to all the tag constructs of C code, member | |
1939 functions are also recognized, and optionally member variables if you | |
1940 use the @samp{--members} option. Tags for variables and functions in | |
1941 classes are named @samp{@var{class}::@var{variable}} and | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1942 @samp{@var{class}::@var{function}}. @code{operator} definitions have |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1943 tag names like @samp{operator+}. |
25829 | 1944 |
1945 @item | |
1946 In Java code, tags include all the constructs recognized in C++, plus | |
26264 | 1947 the @code{interface}, @code{extends} and @code{implements} constructs. |
1948 Tags for variables and functions in classes are named | |
1949 @samp{@var{class}.@var{variable}} and @samp{@var{class}.@var{function}}. | |
25829 | 1950 |
1951 @item | |
1952 In La@TeX{} text, the argument of any of the commands @code{\chapter}, | |
1953 @code{\section}, @code{\subsection}, @code{\subsubsection}, | |
1954 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem}, | |
1955 @code{\part}, @code{\appendix}, @code{\entry}, or @code{\index}, is a | |
1956 tag.@refill | |
1957 | |
1958 Other commands can make tags as well, if you specify them in the | |
29107 | 1959 environment variable @env{TEXTAGS} before invoking @code{etags}. The |
25829 | 1960 value of this environment variable should be a colon-separated list of |
1961 command names. For example, | |
1962 | |
1963 @example | |
1964 TEXTAGS="def:newcommand:newenvironment" | |
1965 export TEXTAGS | |
1966 @end example | |
1967 | |
1968 @noindent | |
1969 specifies (using Bourne shell syntax) that the commands @samp{\def}, | |
1970 @samp{\newcommand} and @samp{\newenvironment} also define tags. | |
1971 | |
1972 @item | |
1973 In Lisp code, any function defined with @code{defun}, any variable | |
1974 defined with @code{defvar} or @code{defconst}, and in general the first | |
1975 argument of any expression that starts with @samp{(def} in column zero, is | |
1976 a tag. | |
1977 | |
1978 @item | |
1979 In Scheme code, tags include anything defined with @code{def} or with a | |
1980 construct whose name starts with @samp{def}. They also include variables | |
1981 set with @code{set!} at top level in the file. | |
1982 @end itemize | |
1983 | |
1984 Several other languages are also supported: | |
1985 | |
1986 @itemize @bullet | |
26264 | 1987 |
1988 @item | |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
1989 In Ada code, functions, procedures, packages, tasks, and types are |
35298
f5b916018b7e
Added instructions for use of Ada tags.
Francesco Potortì <pot@gnu.org>
parents:
35297
diff
changeset
|
1990 tags. Use the @samp{--packages-only} option to create tags for |
f5b916018b7e
Added instructions for use of Ada tags.
Francesco Potortì <pot@gnu.org>
parents:
35297
diff
changeset
|
1991 packages only. |
f5b916018b7e
Added instructions for use of Ada tags.
Francesco Potortì <pot@gnu.org>
parents:
35297
diff
changeset
|
1992 |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1993 In Ada, the same name can be used for different kinds of entity |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1994 (e.g.@:, for a procedure and for a function). Also, for things like |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1995 packages, procedures and functions, there is the spec (i.e.@: the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1996 interface) and the body (i.e.@: the implementation). To make it |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1997 easier to pick the definition you want, Ada tag name have suffixes |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1998 indicating the type of entity: |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
1999 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2000 @table @samp |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2001 @item /b |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2002 package body. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2003 @item /f |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2004 function. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2005 @item /k |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2006 task. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2007 @item /p |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2008 procedure. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2009 @item /s |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2010 package spec. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2011 @item /t |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2012 type. |
35298
f5b916018b7e
Added instructions for use of Ada tags.
Francesco Potortì <pot@gnu.org>
parents:
35297
diff
changeset
|
2013 @end table |
f5b916018b7e
Added instructions for use of Ada tags.
Francesco Potortì <pot@gnu.org>
parents:
35297
diff
changeset
|
2014 |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2015 Thus, @kbd{M-x find-tag @key{RET} bidule/b @key{RET}} will go |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2016 directly to the body of the package @code{bidule}, while @kbd{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2017 find-tag @key{RET} bidule @key{RET}} will just search for any tag |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2018 @code{bidule}. |
26264 | 2019 |
25829 | 2020 @item |
2021 In assembler code, labels appearing at the beginning of a line, | |
2022 followed by a colon, are tags. | |
2023 | |
2024 @item | |
2025 In Bison or Yacc input files, each rule defines as a tag the nonterminal | |
2026 it constructs. The portions of the file that contain C code are parsed | |
2027 as C code. | |
2028 | |
2029 @item | |
2030 In Cobol code, tags are paragraph names; that is, any word starting in | |
2031 column 8 and followed by a period. | |
2032 | |
2033 @item | |
2034 In Erlang code, the tags are the functions, records, and macros defined | |
2035 in the file. | |
2036 | |
2037 @item | |
2038 In Fortran code, functions, subroutines and blockdata are tags. | |
2039 | |
2040 @item | |
35297
e268b7b500f0
Changes for makefile support in etags.
Francesco Potortì <pot@gnu.org>
parents:
35059
diff
changeset
|
2041 In makefiles, targets are tags. |
e268b7b500f0
Changes for makefile support in etags.
Francesco Potortì <pot@gnu.org>
parents:
35059
diff
changeset
|
2042 |
e268b7b500f0
Changes for makefile support in etags.
Francesco Potortì <pot@gnu.org>
parents:
35059
diff
changeset
|
2043 @item |
25829 | 2044 In Objective C code, tags include Objective C definitions for classes, |
2045 class categories, methods, and protocols. | |
2046 | |
2047 @item | |
2048 In Pascal code, the tags are the functions and procedures defined in | |
2049 the file. | |
2050 | |
2051 @item | |
26264 | 2052 In Perl code, the tags are the procedures defined by the @code{sub}, |
2053 @code{my} and @code{local} keywords. Use @samp{--globals} if you want | |
2054 to tag global variables. | |
25829 | 2055 |
2056 @item | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2057 In PostScript code, the tags are the functions. |
25829 | 2058 |
2059 @item | |
2060 In Prolog code, a tag name appears at the left margin. | |
2061 | |
26264 | 2062 @item |
2063 In Python code, @code{def} or @code{class} at the beginning of a line | |
2064 generate a tag. | |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2065 @end itemize |
26264 | 2066 |
26462 | 2067 You can also generate tags based on regexp matching (@pxref{Etags |
26264 | 2068 Regexps}) to handle other formats and languages. |
25829 | 2069 |
2070 @node Create Tags Table | |
2071 @subsection Creating Tags Tables | |
2072 @cindex @code{etags} program | |
2073 | |
2074 The @code{etags} program is used to create a tags table file. It knows | |
2075 the syntax of several languages, as described in | |
2076 @iftex | |
2077 the previous section. | |
2078 @end iftex | |
2079 @ifinfo | |
2080 @ref{Tag Syntax}. | |
2081 @end ifinfo | |
2082 Here is how to run @code{etags}: | |
2083 | |
2084 @example | |
2085 etags @var{inputfiles}@dots{} | |
2086 @end example | |
2087 | |
2088 @noindent | |
26264 | 2089 The @code{etags} program reads the specified files, and writes a tags |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2090 table named @file{TAGS} in the current working directory. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2091 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2092 If the specified files don't exist, @code{etags} looks for |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2093 compressed versions of them and uncompresses them to read them. Under |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2094 MS-DOS, @code{etags} also looks for file names like @file{mycode.cgz} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2095 if it is given @samp{mycode.c} on the command line and @file{mycode.c} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2096 does not exist. |
26264 | 2097 |
2098 @code{etags} recognizes the language used in an input file based on | |
2099 its file name and contents. You can specify the language with the | |
25829 | 2100 @samp{--language=@var{name}} option, described below. |
2101 | |
2102 If the tags table data become outdated due to changes in the files | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2103 described in the table, the way to update the tags table is the same |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2104 way it was made in the first place. But it is not necessary to do |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2105 this very often. |
25829 | 2106 |
2107 If the tags table fails to record a tag, or records it for the wrong | |
2108 file, then Emacs cannot possibly find its definition. However, if the | |
2109 position recorded in the tags table becomes a little bit wrong (due to | |
2110 some editing in the file that the tag definition is in), the only | |
2111 consequence is a slight delay in finding the tag. Even if the stored | |
2112 position is very wrong, Emacs will still find the tag, but it must | |
2113 search the entire file for it. | |
2114 | |
2115 So you should update a tags table when you define new tags that you want | |
2116 to have listed, or when you move tag definitions from one file to another, | |
2117 or when changes become substantial. Normally there is no need to update | |
2118 the tags table after each edit, or even every day. | |
2119 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2120 One tags table can virtually include another. Specify the included |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2121 tags file name with the @samp{--include=@var{file}} option when |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2122 creating the file that is to include it. The latter file then acts as |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2123 if it covered all the source files specified in the included file, as |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2124 well as the files it directly contains. |
25829 | 2125 |
2126 If you specify the source files with relative file names when you run | |
2127 @code{etags}, the tags file will contain file names relative to the | |
2128 directory where the tags file was initially written. This way, you can | |
2129 move an entire directory tree containing both the tags file and the | |
2130 source files, and the tags file will still refer correctly to the source | |
2131 files. | |
2132 | |
2133 If you specify absolute file names as arguments to @code{etags}, then | |
2134 the tags file will contain absolute file names. This way, the tags file | |
2135 will still refer to the same files even if you move it, as long as the | |
2136 source files remain in the same place. Absolute file names start with | |
2137 @samp{/}, or with @samp{@var{device}:/} on MS-DOS and MS-Windows. | |
2138 | |
2139 When you want to make a tags table from a great number of files, you | |
2140 may have problems listing them on the command line, because some systems | |
2141 have a limit on its length. The simplest way to circumvent this limit | |
2142 is to tell @code{etags} to read the file names from its standard input, | |
2143 by typing a dash in place of the file names, like this: | |
2144 | |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2145 @smallexample |
25829 | 2146 find . -name "*.[chCH]" -print | etags - |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2147 @end smallexample |
25829 | 2148 |
2149 Use the option @samp{--language=@var{name}} to specify the language | |
2150 explicitly. You can intermix these options with file names; each one | |
2151 applies to the file names that follow it. Specify | |
2152 @samp{--language=auto} to tell @code{etags} to resume guessing the | |
2153 language from the file names and file contents. Specify | |
2154 @samp{--language=none} to turn off language-specific processing | |
26264 | 2155 entirely; then @code{etags} recognizes tags by regexp matching alone |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2156 (@pxref{Etags Regexps}). |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2157 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2158 @samp{etags --help} prints the list of the languages @code{etags} |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2159 knows, and the file name rules for guessing the language. It also prints |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2160 a list of all the available @code{etags} options, together with a short |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2161 explanation. |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2162 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2163 @node Etags Regexps |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2164 @subsection Etags Regexps |
25829 | 2165 |
2166 The @samp{--regex} option provides a general way of recognizing tags | |
2167 based on regexp matching. You can freely intermix it with file names. | |
2168 Each @samp{--regex} option adds to the preceding ones, and applies only | |
2169 to the following files. The syntax is: | |
2170 | |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2171 @smallexample |
25829 | 2172 --regex=/@var{tagregexp}[/@var{nameregexp}]/ |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2173 @end smallexample |
26264 | 2174 |
25829 | 2175 @noindent |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2176 where @var{tagregexp} is used to match the lines to tag. It is always |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2177 anchored, that is, it behaves as if preceded by @samp{^}. If you want |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2178 to account for indentation, just match any initial number of blanks by |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2179 beginning your regular expression with @samp{[ \t]*}. In the regular |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2180 expressions, @samp{\} quotes the next character, and @samp{\t} stands |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2181 for the tab character. Note that @code{etags} does not handle the other |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2182 C escape sequences for special characters. |
25829 | 2183 |
2184 @cindex interval operator (in regexps) | |
2185 The syntax of regular expressions in @code{etags} is the same as in | |
2186 Emacs, augmented with the @dfn{interval operator}, which works as in | |
2187 @code{grep} and @code{ed}. The syntax of an interval operator is | |
2188 @samp{\@{@var{m},@var{n}\@}}, and its meaning is to match the preceding | |
2189 expression at least @var{m} times and up to @var{n} times. | |
2190 | |
2191 You should not match more characters with @var{tagregexp} than that | |
2192 needed to recognize what you want to tag. If the match is such that | |
26106 | 2193 more characters than needed are unavoidably matched by @var{tagregexp} |
2194 (as will usually be the case), you should add a @var{nameregexp}, to | |
2195 pick out just the tag. This will enable Emacs to find tags more | |
2196 accurately and to do completion on tag names more reliably. You can | |
2197 find some examples below. | |
2198 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2199 The option @samp{--ignore-case-regex} (or @samp{-c}) works like |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2200 @samp{--regex}, except that matching ignores case. This is |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2201 appropriate for certain programming languages. |
25829 | 2202 |
2203 The @samp{-R} option deletes all the regexps defined with | |
2204 @samp{--regex} options. It applies to the file names following it, as | |
2205 you can see from the following example: | |
2206 | |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2207 @smallexample |
25829 | 2208 etags --regex=/@var{reg1}/ voo.doo --regex=/@var{reg2}/ \ |
2209 bar.ber -R --lang=lisp los.er | |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2210 @end smallexample |
25829 | 2211 |
2212 @noindent | |
2213 Here @code{etags} chooses the parsing language for @file{voo.doo} and | |
2214 @file{bar.ber} according to their contents. @code{etags} also uses | |
2215 @var{reg1} to recognize additional tags in @file{voo.doo}, and both | |
2216 @var{reg1} and @var{reg2} to recognize additional tags in | |
2217 @file{bar.ber}. @code{etags} uses the Lisp tags rules, and no regexp | |
2218 matching, to recognize tags in @file{los.er}. | |
2219 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2220 You can specify a regular expression for a particular language, by |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2221 writing @samp{@{lang@}} in front of it. Then @code{etags} will use |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2222 the regular expression only for files of that language. (@samp{etags |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2223 --help} prints the list of languages recognised by @code{etags}.) The |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2224 following example tags the @code{DEFVAR} macros in the Emacs source |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2225 files, for the C language only: |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2226 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2227 @smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2228 --regex='@{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/' |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2229 @end smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2230 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2231 @noindent |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2232 This feature is particularly useful when you store a list of regular |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2233 expressions in a file. The following option syntax instructs |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2234 @code{etags} to read two files of regular expressions. The regular |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2235 expressions contained in the second file are matched without regard to |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2236 case. |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2237 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2238 @smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2239 --regex=@@first-file --ignore-case-regex=@@second-file |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2240 @end smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2241 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2242 @noindent |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2243 A regex file contains one regular expressions per line. Empty lines, |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2244 and lines beginning with space or tab are ignored. When the first |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2245 character in a line is @samp{@@}, @code{etags} assumes that the rest |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2246 of the line is the name of a file of regular expressions; thus, one |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2247 such file can include another file. All the other lines are taken to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2248 be regular expressions. If the first non-whitespace text on the line |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2249 is @samp{--}, that line is a comment. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2250 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2251 For example, one can create a file called @samp{emacs.tags} with the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2252 following contents: |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2253 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2254 @smallexample |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2255 -- This is for GNU Emacs C source files |
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2256 @{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/ |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2257 @end smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2258 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2259 @noindent |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2260 and then use it like this: |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2261 |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2262 @smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2263 etags --regex=@@emacs.tags *.[ch] */*.[ch] |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2264 @end smallexample |
6651db4a4b1f
Document regexp changes in etags.
Francesco Potortì <pot@gnu.org>
parents:
26264
diff
changeset
|
2265 |
25829 | 2266 Here are some more examples. The regexps are quoted to protect them |
2267 from shell interpretation. | |
2268 | |
2269 @itemize @bullet | |
2270 | |
2271 @item | |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2272 Tag Octave files: |
25829 | 2273 |
2274 @smallexample | |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2275 etags --language=none \ |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2276 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \ |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2277 --regex='/###key \(.*\)/\1/' \ |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2278 --regex='/[ \t]*global[ \t].*/' \ |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2279 *.m |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2280 @end smallexample |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2281 |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2282 @noindent |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2283 Note that tags are not generated for scripts, so that you have to add |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2284 a line by yourself of the form @samp{###key @var{scriptname}} if you |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2285 want to jump to it. |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2286 |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2287 @item |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2288 Tag Tcl files: |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2289 |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2290 @smallexample |
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2291 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl |
25829 | 2292 @end smallexample |
2293 | |
2294 @item | |
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potortì <pot@gnu.org>
parents:
26289
diff
changeset
|
2295 Tag VHDL files: |
25829 | 2296 |
2297 @smallexample | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2298 etags --language=none \ |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2299 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \ |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2300 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\ |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2301 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/' |
25829 | 2302 @end smallexample |
2303 @end itemize | |
2304 | |
2305 @node Select Tags Table | |
2306 @subsection Selecting a Tags Table | |
2307 | |
2308 @vindex tags-file-name | |
2309 @findex visit-tags-table | |
2310 Emacs has at any time one @dfn{selected} tags table, and all the commands | |
2311 for working with tags tables use the selected one. To select a tags table, | |
2312 type @kbd{M-x visit-tags-table}, which reads the tags table file name as an | |
2313 argument. The name @file{TAGS} in the default directory is used as the | |
2314 default file name. | |
2315 | |
2316 All this command does is store the file name in the variable | |
2317 @code{tags-file-name}. Emacs does not actually read in the tags table | |
2318 contents until you try to use them. Setting this variable yourself is just | |
2319 as good as using @code{visit-tags-table}. The variable's initial value is | |
2320 @code{nil}; that value tells all the commands for working with tags tables | |
2321 that they must ask for a tags table file name to use. | |
2322 | |
2323 Using @code{visit-tags-table} when a tags table is already loaded | |
2324 gives you a choice: you can add the new tags table to the current list | |
2325 of tags tables, or start a new list. The tags commands use all the tags | |
2326 tables in the current list. If you start a new list, the new tags table | |
2327 is used @emph{instead} of others. If you add the new table to the | |
2328 current list, it is used @emph{as well as} the others. When the tags | |
2329 commands scan the list of tags tables, they don't always start at the | |
2330 beginning of the list; they start with the first tags table (if any) | |
2331 that describes the current file, proceed from there to the end of the | |
2332 list, and then scan from the beginning of the list until they have | |
2333 covered all the tables in the list. | |
2334 | |
2335 @vindex tags-table-list | |
2336 You can specify a precise list of tags tables by setting the variable | |
2337 @code{tags-table-list} to a list of strings, like this: | |
2338 | |
2339 @c keep this on two lines for formatting in smallbook | |
2340 @example | |
2341 @group | |
2342 (setq tags-table-list | |
2343 '("~/emacs" "/usr/local/lib/emacs/src")) | |
2344 @end group | |
2345 @end example | |
2346 | |
2347 @noindent | |
2348 This tells the tags commands to look at the @file{TAGS} files in your | |
2349 @file{~/emacs} directory and in the @file{/usr/local/lib/emacs/src} | |
2350 directory. The order depends on which file you are in and which tags | |
2351 table mentions that file, as explained above. | |
2352 | |
2353 Do not set both @code{tags-file-name} and @code{tags-table-list}. | |
2354 | |
2355 @node Find Tag | |
2356 @subsection Finding a Tag | |
2357 | |
2358 The most important thing that a tags table enables you to do is to find | |
2359 the definition of a specific tag. | |
2360 | |
2361 @table @kbd | |
2362 @item M-.@: @var{tag} @key{RET} | |
2363 Find first definition of @var{tag} (@code{find-tag}). | |
2364 @item C-u M-. | |
2365 Find next alternate definition of last tag specified. | |
2366 @item C-u - M-. | |
2367 Go back to previous tag found. | |
2368 @item C-M-. @var{pattern} @key{RET} | |
2369 Find a tag whose name matches @var{pattern} (@code{find-tag-regexp}). | |
2370 @item C-u C-M-. | |
2371 Find the next tag whose name matches the last pattern used. | |
2372 @item C-x 4 .@: @var{tag} @key{RET} | |
2373 Find first definition of @var{tag}, but display it in another window | |
2374 (@code{find-tag-other-window}). | |
2375 @item C-x 5 .@: @var{tag} @key{RET} | |
2376 Find first definition of @var{tag}, and create a new frame to select the | |
2377 buffer (@code{find-tag-other-frame}). | |
2378 @item M-* | |
2379 Pop back to where you previously invoked @kbd{M-.} and friends. | |
2380 @end table | |
2381 | |
2382 @kindex M-. | |
2383 @findex find-tag | |
2384 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of | |
2385 a specified tag. It searches through the tags table for that tag, as a | |
2386 string, and then uses the tags table info to determine the file that the | |
2387 definition is in and the approximate character position in the file of | |
2388 the definition. Then @code{find-tag} visits that file, moves point to | |
2389 the approximate character position, and searches ever-increasing | |
2390 distances away to find the tag definition. | |
2391 | |
2392 If an empty argument is given (just type @key{RET}), the sexp in the | |
2393 buffer before or around point is used as the @var{tag} argument. | |
2394 @xref{Lists}, for info on sexps. | |
2395 | |
2396 You don't need to give @kbd{M-.} the full name of the tag; a part | |
2397 will do. This is because @kbd{M-.} finds tags in the table which | |
2398 contain @var{tag} as a substring. However, it prefers an exact match | |
2399 to a substring match. To find other tags that match the same | |
2400 substring, give @code{find-tag} a numeric argument, as in @kbd{C-u | |
2401 M-.}; this does not read a tag name, but continues searching the tags | |
2402 table's text for another tag containing the same substring last used. | |
2403 If you have a real @key{META} key, @kbd{M-0 M-.}@: is an easier | |
2404 alternative to @kbd{C-u M-.}. | |
2405 | |
2406 @kindex C-x 4 . | |
2407 @findex find-tag-other-window | |
2408 @kindex C-x 5 . | |
2409 @findex find-tag-other-frame | |
2410 Like most commands that can switch buffers, @code{find-tag} has a | |
2411 variant that displays the new buffer in another window, and one that | |
2412 makes a new frame for it. The former is @kbd{C-x 4 .}, which invokes | |
2413 the command @code{find-tag-other-window}. The latter is @kbd{C-x 5 .}, | |
2414 which invokes @code{find-tag-other-frame}. | |
2415 | |
2416 To move back to places you've found tags recently, use @kbd{C-u - | |
2417 M-.}; more generally, @kbd{M-.} with a negative numeric argument. This | |
2418 command can take you to another buffer. @kbd{C-x 4 .} with a negative | |
2419 argument finds the previous tag location in another window. | |
2420 | |
2421 @kindex M-* | |
2422 @findex pop-tag-mark | |
2423 @vindex find-tag-marker-ring-length | |
2424 As well as going back to places you've found tags recently, you can go | |
2425 back to places @emph{from where} you found them. Use @kbd{M-*}, which | |
2426 invokes the command @code{pop-tag-mark}, for this. Typically you would | |
2427 find and study the definition of something with @kbd{M-.} and then | |
2428 return to where you were with @kbd{M-*}. | |
2429 | |
2430 Both @kbd{C-u - M-.} and @kbd{M-*} allow you to retrace your steps to | |
2431 a depth determined by the variable @code{find-tag-marker-ring-length}. | |
2432 | |
2433 @findex find-tag-regexp | |
2434 @kindex C-M-. | |
2435 The command @kbd{C-M-.} (@code{find-tag-regexp}) visits the tags that | |
2436 match a specified regular expression. It is just like @kbd{M-.} except | |
2437 that it does regexp matching instead of substring matching. | |
2438 | |
2439 @node Tags Search | |
2440 @subsection Searching and Replacing with Tags Tables | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2441 @cindex search and replace in multiple files |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2442 @cindex multiple-file search and replace |
25829 | 2443 |
2444 The commands in this section visit and search all the files listed in the | |
2445 selected tags table, one by one. For these commands, the tags table serves | |
2446 only to specify a sequence of files to search. | |
2447 | |
2448 @table @kbd | |
2449 @item M-x tags-search @key{RET} @var{regexp} @key{RET} | |
2450 Search for @var{regexp} through the files in the selected tags | |
2451 table. | |
2452 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET} | |
2453 Perform a @code{query-replace-regexp} on each file in the selected tags table. | |
2454 @item M-, | |
2455 Restart one of the commands above, from the current location of point | |
2456 (@code{tags-loop-continue}). | |
2457 @end table | |
2458 | |
2459 @findex tags-search | |
2460 @kbd{M-x tags-search} reads a regexp using the minibuffer, then | |
2461 searches for matches in all the files in the selected tags table, one | |
2462 file at a time. It displays the name of the file being searched so you | |
2463 can follow its progress. As soon as it finds an occurrence, | |
2464 @code{tags-search} returns. | |
2465 | |
2466 @kindex M-, | |
2467 @findex tags-loop-continue | |
2468 Having found one match, you probably want to find all the rest. To find | |
2469 one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the | |
2470 @code{tags-search}. This searches the rest of the current buffer, followed | |
2471 by the remaining files of the tags table.@refill | |
2472 | |
2473 @findex tags-query-replace | |
2474 @kbd{M-x tags-query-replace} performs a single | |
2475 @code{query-replace-regexp} through all the files in the tags table. It | |
2476 reads a regexp to search for and a string to replace with, just like | |
2477 ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x | |
2478 tags-search}, but repeatedly, processing matches according to your | |
2479 input. @xref{Replace}, for more information on query replace. | |
2480 | |
31065
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2481 @vindex tags-case-fold-search |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2482 @cindex case-sensitivity and tags search |
31065
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2483 You can control the case-sensitivity of tags search commands by |
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2484 customizing the value of the variable @code{tags-case-fold-search}. The |
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2485 default is to use the same setting as the value of |
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2486 @code{case-fold-search} (@pxref{Search Case}). |
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2487 |
25829 | 2488 It is possible to get through all the files in the tags table with a |
2489 single invocation of @kbd{M-x tags-query-replace}. But often it is | |
2490 useful to exit temporarily, which you can do with any input event that | |
2491 has no special query replace meaning. You can resume the query replace | |
2492 subsequently by typing @kbd{M-,}; this command resumes the last tags | |
2493 search or replace command that you did. | |
2494 | |
2495 The commands in this section carry out much broader searches than the | |
2496 @code{find-tag} family. The @code{find-tag} commands search only for | |
2497 definitions of tags that match your substring or regexp. The commands | |
2498 @code{tags-search} and @code{tags-query-replace} find every occurrence | |
2499 of the regexp, as ordinary search commands and replace commands do in | |
2500 the current buffer. | |
2501 | |
2502 These commands create buffers only temporarily for the files that they | |
2503 have to search (those which are not already visited in Emacs buffers). | |
2504 Buffers in which no match is found are quickly killed; the others | |
2505 continue to exist. | |
2506 | |
2507 It may have struck you that @code{tags-search} is a lot like | |
2508 @code{grep}. You can also run @code{grep} itself as an inferior of | |
2509 Emacs and have Emacs show you the matching lines one by one. This works | |
2510 much like running a compilation; finding the source locations of the | |
2511 @code{grep} matches works like finding the compilation errors. | |
2512 @xref{Compilation}. | |
26264 | 2513 |
25829 | 2514 @node List Tags |
2515 @subsection Tags Table Inquiries | |
2516 | |
2517 @table @kbd | |
2518 @item M-x list-tags @key{RET} @var{file} @key{RET} | |
2519 Display a list of the tags defined in the program file @var{file}. | |
2520 @item M-x tags-apropos @key{RET} @var{regexp} @key{RET} | |
2521 Display a list of all tags matching @var{regexp}. | |
2522 @end table | |
2523 | |
2524 @findex list-tags | |
2525 @kbd{M-x list-tags} reads the name of one of the files described by | |
2526 the selected tags table, and displays a list of all the tags defined in | |
2527 that file. The ``file name'' argument is really just a string to | |
2528 compare against the file names recorded in the tags table; it is read as | |
2529 a string rather than as a file name. Therefore, completion and | |
2530 defaulting are not available, and you must enter the file name the same | |
2531 way it appears in the tags table. Do not include a directory as part of | |
2532 the file name unless the file name recorded in the tags table includes a | |
2533 directory. | |
2534 | |
2535 @findex tags-apropos | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2536 @vindex tags-apropos-verbose |
25829 | 2537 @kbd{M-x tags-apropos} is like @code{apropos} for tags |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2538 (@pxref{Apropos}). It finds all the tags in the selected tags table |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2539 whose entries match @var{regexp}, and displays them. If the variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2540 @code{tags-apropos-verbose} is non-@code{nil}, it displays the names |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2541 of the tags files together with the tag names. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2542 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2543 @vindex tags-tag-face |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2544 @vindex tags-apropos-additional-actions |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2545 You can customize the appearance of the output with the face |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2546 @code{tags-tag-face}. You can display additional output with @kbd{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2547 tags-apropos} by customizing the variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2548 @code{tags-apropos-additional-actions}---see its documentation for |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2549 details. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2550 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2551 You can also use the collection of tag names to complete a symbol |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2552 name in the buffer. @xref{Symbol Completion}. |
25829 | 2553 |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2554 @node Imenu |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2555 @section Imenu |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2556 @cindex indexes of buffer contents |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2557 @cindex buffer content indexes |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2558 @cindex tags |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2559 |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2560 The Imenu facility is another way to find definitions or sections |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2561 in a file. It is similar in spirit to Tags, but operates on a single |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2562 buffer only, and works entirely within Emacs with no need for a separate |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2563 tags table. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2564 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2565 @findex imenu |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2566 @findex imenu-add-menu-bar-index |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2567 If you type @kbd{M-x imenu}, it reads the name of a section or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2568 definition in the current buffer, then goes to that section or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2569 definition. You can use completion to specify the name, and a |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2570 complete list of possible names is always displayed. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2571 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2572 Alternatively you can bind the command @code{imenu} to a mouse |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2573 click. Then it displays mouse menus for you to select the section or |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2574 definition you want. You can also add the buffer's index to the menu |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2575 bar by calling @code{imenu-add-menu-bar-index}. If you want to have |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2576 this menu bar item available for all buffers in a certain major mode, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2577 you can do this by adding @code{imenu-add-menu-bar-index} to its mode |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2578 hook. But then you will have to wait for the buffer to be searched |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2579 for sections and definitions, each time you visit a file which uses |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2580 that mode. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2581 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2582 @vindex imenu-auto-rescan |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2583 When you change the contents of a buffer, if you add or delete |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2584 definitions or sections, you can update the buffer's index to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2585 correspond to the new contents by invoking the @samp{*Rescan*} item in |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2586 the menu. Rescanning happens automatically if |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2587 @code{imenu-auto-rescan} is non-@code{nil}. There is no need to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2588 rescan because of small changes in the text. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2589 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2590 @vindex imenu-sort-function |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2591 You can customize the way the menus are sorted via the variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2592 @code{imenu-sort-function}. By default names are ordered as they |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2593 occur in the buffer; alphabetic sorting is provided as an alternative. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2594 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2595 Imenu provides the information to guide Which Function mode |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2596 (@pxref{Which Function}). The Speedbar can also use it |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
2597 (@pxref{Speedbar}). |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2598 |
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2599 @node Emerge, C Modes, Imenu, Programs |
25829 | 2600 @section Merging Files with Emerge |
2601 @cindex Emerge | |
2602 @cindex merging files | |
2603 | |
2604 It's not unusual for programmers to get their signals crossed and modify | |
2605 the same program in two different directions. To recover from this | |
2606 confusion, you need to merge the two versions. Emerge makes this | |
2607 easier. See also @ref{Comparing Files}, for commands to compare | |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
2608 in a more manual fashion, and @ref{,Ediff,, ediff, The Ediff Manual}. |
25829 | 2609 |
2610 @menu | |
2611 * Overview of Emerge:: How to start Emerge. Basic concepts. | |
2612 * Submodes of Emerge:: Fast mode vs. Edit mode. | |
2613 Skip Prefers mode and Auto Advance mode. | |
2614 * State of Difference:: You do the merge by specifying state A or B | |
2615 for each difference. | |
2616 * Merge Commands:: Commands for selecting a difference, | |
2617 changing states of differences, etc. | |
2618 * Exiting Emerge:: What to do when you've finished the merge. | |
2619 * Combining in Emerge:: How to keep both alternatives for a difference. | |
2620 * Fine Points of Emerge:: Misc. | |
2621 @end menu | |
2622 | |
2623 @node Overview of Emerge | |
2624 @subsection Overview of Emerge | |
2625 | |
2626 To start Emerge, run one of these four commands: | |
2627 | |
2628 @table @kbd | |
2629 @item M-x emerge-files | |
2630 @findex emerge-files | |
2631 Merge two specified files. | |
2632 | |
2633 @item M-x emerge-files-with-ancestor | |
2634 @findex emerge-files-with-ancestor | |
2635 Merge two specified files, with reference to a common ancestor. | |
2636 | |
2637 @item M-x emerge-buffers | |
2638 @findex emerge-buffers | |
2639 Merge two buffers. | |
2640 | |
2641 @item M-x emerge-buffers-with-ancestor | |
2642 @findex emerge-buffers-with-ancestor | |
2643 Merge two buffers with reference to a common ancestor in a third | |
2644 buffer. | |
2645 @end table | |
2646 | |
2647 @cindex merge buffer (Emerge) | |
2648 @cindex A and B buffers (Emerge) | |
2649 The Emerge commands compare two files or buffers, and display the | |
2650 comparison in three buffers: one for each input text (the @dfn{A buffer} | |
2651 and the @dfn{B buffer}), and one (the @dfn{merge buffer}) where merging | |
2652 takes place. The merge buffer shows the full merged text, not just the | |
2653 differences. Wherever the two input texts differ, you can choose which | |
2654 one of them to include in the merge buffer. | |
2655 | |
2656 The Emerge commands that take input from existing buffers use only the | |
2657 accessible portions of those buffers, if they are narrowed | |
2658 (@pxref{Narrowing}). | |
2659 | |
2660 If a common ancestor version is available, from which the two texts to | |
2661 be merged were both derived, Emerge can use it to guess which | |
2662 alternative is right. Wherever one current version agrees with the | |
2663 ancestor, Emerge presumes that the other current version is a deliberate | |
2664 change which should be kept in the merged version. Use the | |
2665 @samp{with-ancestor} commands if you want to specify a common ancestor | |
2666 text. These commands read three file or buffer names---variant A, | |
2667 variant B, and the common ancestor. | |
2668 | |
2669 After the comparison is done and the buffers are prepared, the | |
2670 interactive merging starts. You control the merging by typing special | |
2671 @dfn{merge commands} in the merge buffer. The merge buffer shows you a | |
2672 full merged text, not just differences. For each run of differences | |
2673 between the input texts, you can choose which one of them to keep, or | |
2674 edit them both together. | |
2675 | |
2676 The merge buffer uses a special major mode, Emerge mode, with commands | |
2677 for making these choices. But you can also edit the buffer with | |
2678 ordinary Emacs commands. | |
2679 | |
2680 At any given time, the attention of Emerge is focused on one | |
2681 particular difference, called the @dfn{selected} difference. This | |
2682 difference is marked off in the three buffers like this: | |
2683 | |
2684 @example | |
2685 vvvvvvvvvvvvvvvvvvvv | |
2686 @var{text that differs} | |
2687 ^^^^^^^^^^^^^^^^^^^^ | |
2688 @end example | |
2689 | |
2690 @noindent | |
2691 Emerge numbers all the differences sequentially and the mode | |
2692 line always shows the number of the selected difference. | |
2693 | |
2694 Normally, the merge buffer starts out with the A version of the text. | |
2695 But when the A version of a difference agrees with the common ancestor, | |
2696 then the B version is initially preferred for that difference. | |
2697 | |
2698 Emerge leaves the merged text in the merge buffer when you exit. At | |
2699 that point, you can save it in a file with @kbd{C-x C-w}. If you give a | |
2700 numeric argument to @code{emerge-files} or | |
2701 @code{emerge-files-with-ancestor}, it reads the name of the output file | |
2702 using the minibuffer. (This is the last file name those commands read.) | |
2703 Then exiting from Emerge saves the merged text in the output file. | |
2704 | |
2705 Normally, Emerge commands save the output buffer in its file when you | |
2706 exit. If you abort Emerge with @kbd{C-]}, the Emerge command does not | |
2707 save the output buffer, but you can save it yourself if you wish. | |
2708 | |
2709 @node Submodes of Emerge | |
2710 @subsection Submodes of Emerge | |
2711 | |
2712 You can choose between two modes for giving merge commands: Fast mode | |
2713 and Edit mode. In Fast mode, basic merge commands are single | |
2714 characters, but ordinary Emacs commands are disabled. This is | |
2715 convenient if you use only merge commands. In Edit mode, all merge | |
2716 commands start with the prefix key @kbd{C-c C-c}, and the normal Emacs | |
2717 commands are also available. This allows editing the merge buffer, but | |
2718 slows down Emerge operations. | |
2719 | |
2720 Use @kbd{e} to switch to Edit mode, and @kbd{C-c C-c f} to switch to | |
2721 Fast mode. The mode line indicates Edit and Fast modes with @samp{E} | |
2722 and @samp{F}. | |
2723 | |
2724 Emerge has two additional submodes that affect how particular merge | |
2725 commands work: Auto Advance mode and Skip Prefers mode. | |
2726 | |
2727 If Auto Advance mode is in effect, the @kbd{a} and @kbd{b} commands | |
2728 advance to the next difference. This lets you go through the merge | |
2729 faster as long as you simply choose one of the alternatives from the | |
2730 input. The mode line indicates Auto Advance mode with @samp{A}. | |
2731 | |
2732 If Skip Prefers mode is in effect, the @kbd{n} and @kbd{p} commands | |
2733 skip over differences in states prefer-A and prefer-B (@pxref{State of | |
2734 Difference}). Thus you see only differences for which neither version | |
2735 is presumed ``correct.'' The mode line indicates Skip Prefers mode with | |
2736 @samp{S}. | |
2737 | |
2738 @findex emerge-auto-advance-mode | |
2739 @findex emerge-skip-prefers-mode | |
2740 Use the command @kbd{s a} (@code{emerge-auto-advance-mode}) to set or | |
2741 clear Auto Advance mode. Use @kbd{s s} | |
2742 (@code{emerge-skip-prefers-mode}) to set or clear Skip Prefers mode. | |
2743 These commands turn on the mode with a positive argument, turns it off | |
2744 with a negative or zero argument, and toggle the mode with no argument. | |
2745 | |
2746 @node State of Difference | |
2747 @subsection State of a Difference | |
2748 | |
2749 In the merge buffer, a difference is marked with lines of @samp{v} and | |
2750 @samp{^} characters. Each difference has one of these seven states: | |
2751 | |
2752 @table @asis | |
2753 @item A | |
2754 The difference is showing the A version. The @kbd{a} command always | |
2755 produces this state; the mode line indicates it with @samp{A}. | |
2756 | |
2757 @item B | |
2758 The difference is showing the B version. The @kbd{b} command always | |
2759 produces this state; the mode line indicates it with @samp{B}. | |
2760 | |
2761 @item default-A | |
2762 @itemx default-B | |
2763 The difference is showing the A or the B state by default, because you | |
2764 haven't made a choice. All differences start in the default-A state | |
2765 (and thus the merge buffer is a copy of the A buffer), except those for | |
2766 which one alternative is ``preferred'' (see below). | |
2767 | |
2768 When you select a difference, its state changes from default-A or | |
2769 default-B to plain A or B. Thus, the selected difference never has | |
2770 state default-A or default-B, and these states are never displayed in | |
2771 the mode line. | |
2772 | |
2773 The command @kbd{d a} chooses default-A as the default state, and @kbd{d | |
2774 b} chooses default-B. This chosen default applies to all differences | |
2775 which you haven't ever selected and for which no alternative is preferred. | |
2776 If you are moving through the merge sequentially, the differences you | |
2777 haven't selected are those following the selected one. Thus, while | |
2778 moving sequentially, you can effectively make the A version the default | |
2779 for some sections of the merge buffer and the B version the default for | |
2780 others by using @kbd{d a} and @kbd{d b} between sections. | |
2781 | |
2782 @item prefer-A | |
2783 @itemx prefer-B | |
2784 The difference is showing the A or B state because it is | |
2785 @dfn{preferred}. This means that you haven't made an explicit choice, | |
2786 but one alternative seems likely to be right because the other | |
2787 alternative agrees with the common ancestor. Thus, where the A buffer | |
2788 agrees with the common ancestor, the B version is preferred, because | |
2789 chances are it is the one that was actually changed. | |
2790 | |
2791 These two states are displayed in the mode line as @samp{A*} and @samp{B*}. | |
2792 | |
2793 @item combined | |
2794 The difference is showing a combination of the A and B states, as a | |
2795 result of the @kbd{x c} or @kbd{x C} commands. | |
2796 | |
2797 Once a difference is in this state, the @kbd{a} and @kbd{b} commands | |
2798 don't do anything to it unless you give them a numeric argument. | |
2799 | |
2800 The mode line displays this state as @samp{comb}. | |
2801 @end table | |
2802 | |
2803 @node Merge Commands | |
2804 @subsection Merge Commands | |
2805 | |
2806 Here are the Merge commands for Fast mode; in Edit mode, precede them | |
2807 with @kbd{C-c C-c}: | |
2808 | |
2809 @table @kbd | |
2810 @item p | |
2811 Select the previous difference. | |
2812 | |
2813 @item n | |
2814 Select the next difference. | |
2815 | |
2816 @item a | |
2817 Choose the A version of this difference. | |
2818 | |
2819 @item b | |
2820 Choose the B version of this difference. | |
2821 | |
2822 @item C-u @var{n} j | |
2823 Select difference number @var{n}. | |
2824 | |
2825 @item . | |
2826 Select the difference containing point. You can use this command in the | |
2827 merge buffer or in the A or B buffer. | |
2828 | |
2829 @item q | |
2830 Quit---finish the merge. | |
2831 | |
2832 @item C-] | |
2833 Abort---exit merging and do not save the output. | |
2834 | |
2835 @item f | |
2836 Go into Fast mode. (In Edit mode, this is actually @kbd{C-c C-c f}.) | |
2837 | |
2838 @item e | |
2839 Go into Edit mode. | |
2840 | |
2841 @item l | |
2842 Recenter (like @kbd{C-l}) all three windows. | |
2843 | |
26264 | 2844 @item - |
25829 | 2845 Specify part of a prefix numeric argument. |
2846 | |
2847 @item @var{digit} | |
2848 Also specify part of a prefix numeric argument. | |
2849 | |
2850 @item d a | |
2851 Choose the A version as the default from here down in | |
2852 the merge buffer. | |
2853 | |
2854 @item d b | |
2855 Choose the B version as the default from here down in | |
2856 the merge buffer. | |
2857 | |
2858 @item c a | |
2859 Copy the A version of this difference into the kill ring. | |
2860 | |
2861 @item c b | |
2862 Copy the B version of this difference into the kill ring. | |
2863 | |
2864 @item i a | |
2865 Insert the A version of this difference at point. | |
2866 | |
2867 @item i b | |
2868 Insert the B version of this difference at point. | |
2869 | |
2870 @item m | |
2871 Put point and mark around the difference. | |
2872 | |
2873 @item ^ | |
2874 Scroll all three windows down (like @kbd{M-v}). | |
2875 | |
2876 @item v | |
2877 Scroll all three windows up (like @kbd{C-v}). | |
2878 | |
2879 @item < | |
2880 Scroll all three windows left (like @kbd{C-x <}). | |
2881 | |
2882 @item > | |
2883 Scroll all three windows right (like @kbd{C-x >}). | |
2884 | |
2885 @item | | |
2886 Reset horizontal scroll on all three windows. | |
2887 | |
2888 @item x 1 | |
2889 Shrink the merge window to one line. (Use @kbd{C-u l} to restore it | |
2890 to full size.) | |
2891 | |
2892 @item x c | |
2893 Combine the two versions of this difference (@pxref{Combining in | |
2894 Emerge}). | |
2895 | |
2896 @item x f | |
2897 Show the names of the files/buffers Emerge is operating on, in a Help | |
2898 window. (Use @kbd{C-u l} to restore windows.) | |
2899 | |
2900 @item x j | |
2901 Join this difference with the following one. | |
2902 (@kbd{C-u x j} joins this difference with the previous one.) | |
2903 | |
2904 @item x s | |
2905 Split this difference into two differences. Before you use this | |
2906 command, position point in each of the three buffers at the place where | |
2907 you want to split the difference. | |
2908 | |
2909 @item x t | |
2910 Trim identical lines off the top and bottom of the difference. | |
2911 Such lines occur when the A and B versions are | |
2912 identical but differ from the ancestor version. | |
2913 @end table | |
2914 | |
2915 @node Exiting Emerge | |
2916 @subsection Exiting Emerge | |
2917 | |
2918 The @kbd{q} command (@code{emerge-quit}) finishes the merge, storing | |
2919 the results into the output file if you specified one. It restores the | |
2920 A and B buffers to their proper contents, or kills them if they were | |
2921 created by Emerge and you haven't changed them. It also disables the | |
2922 Emerge commands in the merge buffer, since executing them later could | |
2923 damage the contents of the various buffers. | |
2924 | |
2925 @kbd{C-]} aborts the merge. This means exiting without writing the | |
2926 output file. If you didn't specify an output file, then there is no | |
2927 real difference between aborting and finishing the merge. | |
2928 | |
2929 If the Emerge command was called from another Lisp program, then its | |
2930 return value is @code{t} for successful completion, or @code{nil} if you | |
2931 abort. | |
2932 | |
2933 @node Combining in Emerge | |
2934 @subsection Combining the Two Versions | |
2935 | |
2936 Sometimes you want to keep @emph{both} alternatives for a particular | |
2937 difference. To do this, use @kbd{x c}, which edits the merge buffer | |
2938 like this: | |
2939 | |
2940 @example | |
2941 @group | |
2942 #ifdef NEW | |
2943 @var{version from A buffer} | |
2944 #else /* not NEW */ | |
2945 @var{version from B buffer} | |
2946 #endif /* not NEW */ | |
2947 @end group | |
2948 @end example | |
2949 | |
2950 @noindent | |
2951 @vindex emerge-combine-versions-template | |
2952 While this example shows C preprocessor conditionals delimiting the two | |
2953 alternative versions, you can specify the strings to use by setting | |
2954 the variable @code{emerge-combine-versions-template} to a string of your | |
2955 choice. In the string, @samp{%a} says where to put version A, and | |
2956 @samp{%b} says where to put version B. The default setting, which | |
2957 produces the results shown above, looks like this: | |
2958 | |
2959 @example | |
2960 @group | |
2961 "#ifdef NEW\n%a#else /* not NEW */\n%b#endif /* not NEW */\n" | |
2962 @end group | |
2963 @end example | |
2964 | |
2965 @node Fine Points of Emerge | |
2966 @subsection Fine Points of Emerge | |
2967 | |
2968 During the merge, you mustn't try to edit the A and B buffers yourself. | |
2969 Emerge modifies them temporarily, but ultimately puts them back the way | |
2970 they were. | |
2971 | |
2972 You can have any number of merges going at once---just don't use any one | |
2973 buffer as input to more than one merge at once, since the temporary | |
2974 changes made in these buffers would get in each other's way. | |
2975 | |
2976 Starting Emerge can take a long time because it needs to compare the | |
2977 files fully. Emacs can't do anything else until @code{diff} finishes. | |
2978 Perhaps in the future someone will change Emerge to do the comparison in | |
2979 the background when the input files are large---then you could keep on | |
2980 doing other things with Emacs until Emerge is ready to accept | |
2981 commands. | |
2982 | |
2983 @vindex emerge-startup-hook | |
2984 After setting up the merge, Emerge runs the hook | |
2985 @code{emerge-startup-hook} (@pxref{Hooks}). | |
2986 | |
2987 @node C Modes | |
2988 @section C and Related Modes | |
2989 @cindex C mode | |
2990 @cindex Java mode | |
2991 @cindex Pike mode | |
2992 @cindex IDL mode | |
2993 @cindex CORBA IDL mode | |
2994 @cindex Objective C mode | |
2995 @cindex C++ mode | |
2996 @cindex mode, Java | |
2997 @cindex mode, C | |
2998 @cindex mode, Objective C | |
2999 @cindex mode, CORBA IDL | |
3000 @cindex mode, Pike | |
3001 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3002 This section gives a brief description of the special features |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3003 available in C, C++, Objective-C, Java, CORBA IDL, and Pike modes. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3004 (These are called ``C mode and related modes.'') @xref{Top, CC Mode, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3005 ccmode, , CC Mode}, for a more extensive description of these modes |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3006 and their special features. |
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
3007 |
25829 | 3008 @menu |
3009 * Motion in C:: | |
3010 * Electric C:: | |
3011 * Hungry Delete:: | |
3012 * Other C Commands:: | |
3013 * Comments in C:: | |
3014 @end menu | |
3015 | |
3016 @node Motion in C | |
3017 @subsection C Mode Motion Commands | |
3018 | |
3019 This section describes commands for moving point, in C mode and | |
3020 related modes. | |
3021 | |
3022 @table @code | |
3023 @item C-c C-u | |
3024 @kindex C-c C-u @r{(C mode)} | |
3025 @findex c-up-conditional | |
3026 Move point back to the containing preprocessor conditional, leaving the | |
3027 mark behind. A prefix argument acts as a repeat count. With a negative | |
3028 argument, move point forward to the end of the containing | |
3029 preprocessor conditional. When going backwards, @code{#elif} is treated | |
3030 like @code{#else} followed by @code{#if}. When going forwards, | |
3031 @code{#elif} is ignored.@refill | |
3032 | |
3033 @item C-c C-p | |
3034 @kindex C-c C-p @r{(C mode)} | |
3035 @findex c-backward-conditional | |
3036 Move point back over a preprocessor conditional, leaving the mark | |
3037 behind. A prefix argument acts as a repeat count. With a negative | |
3038 argument, move forward. | |
3039 | |
3040 @item C-c C-n | |
3041 @kindex C-c C-n @r{(C mode)} | |
3042 @findex c-forward-conditional | |
3043 Move point forward across a preprocessor conditional, leaving the mark | |
3044 behind. A prefix argument acts as a repeat count. With a negative | |
3045 argument, move backward. | |
3046 | |
3047 @item M-a | |
3048 @kindex ESC a | |
3049 @findex c-beginning-of-statement | |
3050 Move point to the beginning of the innermost C statement | |
3051 (@code{c-beginning-of-statement}). If point is already at the beginning | |
3052 of a statement, move to the beginning of the preceding statement. With | |
3053 prefix argument @var{n}, move back @var{n} @minus{} 1 statements. | |
3054 | |
3055 If point is within a string or comment, or next to a comment (only | |
3056 whitespace between them), this command moves by sentences instead of | |
3057 statements. | |
3058 | |
3059 When called from a program, this function takes three optional | |
3060 arguments: the numeric prefix argument, a buffer position limit | |
3061 (don't move back before that place), and a flag that controls whether | |
3062 to do sentence motion when inside of a comment. | |
3063 | |
3064 @item M-e | |
3065 @kindex ESC e | |
3066 @findex c-end-of-statement | |
3067 Move point to the end of the innermost C statement; like @kbd{M-a} | |
3068 except that it moves in the other direction (@code{c-end-of-statement}). | |
3069 | |
3070 @item M-x c-backward-into-nomenclature | |
3071 @findex c-backward-into-nomenclature | |
3072 Move point backward to beginning of a C++ nomenclature section or word. | |
3073 With prefix argument @var{n}, move @var{n} times. If @var{n} is | |
3074 negative, move forward. C++ nomenclature means a symbol name in the | |
3075 style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital letter | |
3076 begins a section or word. | |
3077 | |
3078 In the GNU project, we recommend using underscores to separate words | |
3079 within an identifier in C or C++, rather than using case distinctions. | |
3080 | |
3081 @item M-x c-forward-into-nomenclature | |
3082 @findex c-forward-into-nomenclature | |
3083 Move point forward to end of a C++ nomenclature section or word. | |
3084 With prefix argument @var{n}, move @var{n} times. | |
3085 @end table | |
3086 | |
3087 @node Electric C | |
3088 @subsection Electric C Characters | |
3089 | |
3090 In C mode and related modes, certain printing characters are | |
3091 ``electric''---in addition to inserting themselves, they also reindent | |
3092 the current line and may insert newlines. This feature is controlled by | |
3093 the variable @code{c-auto-newline}. The ``electric'' characters are | |
3094 @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#}, @kbd{;}, @kbd{,}, @kbd{<}, | |
3095 @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and @kbd{)}. | |
3096 | |
3097 Electric characters insert newlines only when the @dfn{auto-newline} | |
3098 feature is enabled (indicated by @samp{/a} in the mode line after the | |
3099 mode name). This feature is controlled by the variable | |
3100 @code{c-auto-newline}. You can turn this feature on or off with the | |
3101 command @kbd{C-c C-a}: | |
3102 | |
3103 @table @kbd | |
3104 @item C-c C-a | |
3105 @kindex C-c C-a @r{(C mode)} | |
3106 @findex c-toggle-auto-state | |
3107 Toggle the auto-newline feature (@code{c-toggle-auto-state}). With a | |
3108 prefix argument, this command turns the auto-newline feature on if the | |
3109 argument is positive, and off if it is negative. | |
3110 @end table | |
3111 | |
3112 The colon character is electric because that is appropriate for a | |
3113 single colon. But when you want to insert a double colon in C++, the | |
3114 electric behavior of colon is inconvenient. You can insert a double | |
3115 colon with no reindentation or newlines by typing @kbd{C-c :}: | |
3116 | |
3117 @table @kbd | |
3118 @item C-c : | |
3119 @kindex C-c : @r{(C mode)} | |
3120 @findex c-scope-operator | |
3121 Insert a double colon scope operator at point, without reindenting the | |
3122 line or adding any newlines (@code{c-scope-operator}). | |
3123 @end table | |
3124 | |
3125 The electric @kbd{#} key reindents the line if it appears to be the | |
3126 beginning of a preprocessor directive. This happens when the value of | |
3127 @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn | |
3128 this feature off by setting @code{c-electric-pound-behavior} to | |
3129 @code{nil}. | |
3130 | |
3131 The variable @code{c-hanging-braces-alist} controls the insertion of | |
3132 newlines before and after inserted braces. It is an association list | |
3133 with elements of the following form: @code{(@var{syntactic-symbol} | |
3134 . @var{nl-list})}. Most of the syntactic symbols that appear in | |
3135 @code{c-offsets-alist} are meaningful here as well. | |
3136 | |
3137 The list @var{nl-list} may contain either of the symbols | |
3138 @code{before} or @code{after}, or both; or it may be @code{nil}. When a | |
3139 brace is inserted, the syntactic context it defines is looked up in | |
3140 @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used | |
3141 to determine where newlines are inserted: either before the brace, | |
3142 after, or both. If not found, the default is to insert a newline both | |
3143 before and after braces. | |
3144 | |
3145 The variable @code{c-hanging-colons-alist} controls the insertion of | |
3146 newlines before and after inserted colons. It is an association list | |
3147 with elements of the following form: @code{(@var{syntactic-symbol} | |
3148 . @var{nl-list})}. The list @var{nl-list} may contain either of the | |
3149 symbols @code{before} or @code{after}, or both; or it may be @code{nil}. | |
3150 | |
3151 When a colon is inserted, the syntactic symbol it defines is looked | |
3152 up in this list, and if found, the @var{nl-list} is used to determine | |
3153 where newlines are inserted: either before the brace, after, or both. | |
3154 If the syntactic symbol is not found in this list, no newlines are | |
3155 inserted. | |
3156 | |
3157 Electric characters can also delete newlines automatically when the | |
3158 auto-newline feature is enabled. This feature makes auto-newline more | |
3159 acceptable, by deleting the newlines in the most common cases where you | |
3160 do not want them. Emacs can recognize several cases in which deleting a | |
3161 newline might be desirable; by setting the variable | |
3162 @code{c-cleanup-list}, you can specify @emph{which} of these cases that | |
3163 should happen. The variable's value is a list of symbols, each | |
3164 describing one case for possible deletion of a newline. Here are the | |
3165 meaningful symbols, and their meanings: | |
3166 | |
3167 @table @code | |
3168 @item brace-catch-brace | |
3169 Clean up @samp{@} catch (@var{condition}) @{} constructs by placing the | |
3170 entire construct on a single line. The clean-up occurs when you type | |
3171 the @samp{@{}, if there is nothing between the braces aside from | |
3172 @code{catch} and @var{condition}. | |
3173 | |
3174 @item brace-else-brace | |
3175 Clean up @samp{@} else @{} constructs by placing the entire construct on | |
3176 a single line. The clean-up occurs when you type the @samp{@{} after | |
3177 the @code{else}, but only if there is nothing but white space between | |
3178 the braces and the @code{else}. | |
3179 | |
3180 @item brace-elseif-brace | |
3181 Clean up @samp{@} else if (@dots{}) @{} constructs by placing the entire | |
3182 construct on a single line. The clean-up occurs when you type the | |
3183 @samp{@{}, if there is nothing but white space between the @samp{@}} and | |
3184 @samp{@{} aside from the keywords and the @code{if}-condition. | |
3185 | |
3186 @item empty-defun-braces | |
3187 Clean up empty defun braces by placing the braces on the same | |
3188 line. Clean-up occurs when you type the closing brace. | |
3189 | |
3190 @item defun-close-semi | |
3191 Clean up the semicolon after a @code{struct} or similar type | |
3192 declaration, by placing the semicolon on the same line as the closing | |
3193 brace. Clean-up occurs when you type the semicolon. | |
3194 | |
3195 @item list-close-comma | |
3196 Clean up commas following braces in array and aggregate | |
3197 initializers. Clean-up occurs when you type the comma. | |
3198 | |
3199 @item scope-operator | |
3200 Clean up double colons which may designate a C++ scope operator, by | |
3201 placing the colons together. Clean-up occurs when you type the second | |
3202 colon, but only when the two colons are separated by nothing but | |
3203 whitespace. | |
3204 @end table | |
3205 | |
3206 @node Hungry Delete | |
3207 @subsection Hungry Delete Feature in C | |
3208 | |
3209 When the @dfn{hungry-delete} feature is enabled (indicated by | |
3210 @samp{/h} or @samp{/ah} in the mode line after the mode name), a single | |
3211 @key{DEL} command deletes all preceding whitespace, not just one space. | |
3212 To turn this feature on or off, use @kbd{C-c C-d}: | |
3213 | |
3214 @table @kbd | |
3215 @item C-c C-d | |
3216 @kindex C-c C-d @r{(C mode)} | |
3217 @findex c-toggle-hungry-state | |
3218 Toggle the hungry-delete feature (@code{c-toggle-hungry-state}). With a | |
3219 prefix argument, this command turns the hungry-delete feature on if the | |
3220 argument is positive, and off if it is negative. | |
3221 | |
3222 @item C-c C-t | |
3223 @kindex C-c C-t @r{(C mode)} | |
3224 @findex c-toggle-auto-hungry-state | |
3225 Toggle the auto-newline and hungry-delete features, both at once | |
3226 (@code{c-toggle-auto-hungry-state}). | |
3227 @end table | |
3228 | |
3229 @vindex c-hungry-delete-key | |
3230 The variable @code{c-hungry-delete-key} controls whether the | |
3231 hungry-delete feature is enabled. | |
3232 | |
3233 @node Other C Commands | |
3234 @subsection Other Commands for C Mode | |
3235 | |
3236 @table @kbd | |
3237 @item C-M-h | |
3238 Put mark at the end of a function definition, and put point at the | |
3239 beginning (@code{c-mark-function}). | |
3240 | |
3241 @item M-q | |
3242 @kindex M-q @r{(C mode)} | |
3243 @findex c-fill-paragraph | |
3244 Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}). | |
3245 If any part of the current line is a comment or within a comment, this | |
3246 command fills the comment or the paragraph of it that point is in, | |
3247 preserving the comment indentation and comment delimiters. | |
3248 | |
3249 @item C-c C-e | |
3250 @cindex macro expansion in C | |
3251 @cindex expansion of C macros | |
3252 @findex c-macro-expand | |
3253 @kindex C-c C-e @r{(C mode)} | |
3254 Run the C preprocessor on the text in the region, and show the result, | |
3255 which includes the expansion of all the macro calls | |
3256 (@code{c-macro-expand}). The buffer text before the region is also | |
3257 included in preprocessing, for the sake of macros defined there, but the | |
3258 output from this part isn't shown. | |
3259 | |
3260 When you are debugging C code that uses macros, sometimes it is hard to | |
3261 figure out precisely how the macros expand. With this command, you | |
3262 don't have to figure it out; you can see the expansions. | |
3263 | |
3264 @item C-c C-\ | |
3265 @findex c-backslash-region | |
3266 @kindex C-c C-\ @r{(C mode)} | |
3267 Insert or align @samp{\} characters at the ends of the lines of the | |
3268 region (@code{c-backslash-region}). This is useful after writing or | |
3269 editing a C macro definition. | |
3270 | |
3271 If a line already ends in @samp{\}, this command adjusts the amount of | |
3272 whitespace before it. Otherwise, it inserts a new @samp{\}. However, | |
3273 the last line in the region is treated specially; no @samp{\} is | |
3274 inserted on that line, and any @samp{\} there is deleted. | |
3275 | |
3276 @item M-x cpp-highlight-buffer | |
3277 @cindex preprocessor highlighting | |
3278 @findex cpp-highlight-buffer | |
3279 Highlight parts of the text according to its preprocessor conditionals. | |
3280 This command displays another buffer named @samp{*CPP Edit*}, which | |
3281 serves as a graphic menu for selecting how to display particular kinds | |
3282 of conditionals and their contents. After changing various settings, | |
3283 click on @samp{[A]pply these settings} (or go to that buffer and type | |
3284 @kbd{a}) to rehighlight the C mode buffer accordingly. | |
3285 | |
3286 @item C-c C-s | |
3287 @findex c-show-syntactic-information | |
3288 @kindex C-c C-s @r{(C mode)} | |
3289 Display the syntactic information about the current source line | |
3290 (@code{c-show-syntactic-information}). This is the information that | |
3291 directs how the line is indented. | |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3292 |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3293 @item M-x cwarn-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3294 @itemx M-x global-cwarn-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3295 @findex cwarn-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3296 @findex global-cwarn-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3297 @cindex CWarn mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3298 @cindex suspicious constructions in C, C++ |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3299 CWarn minor mode highlights certain suspicious C and C++ constructions: |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3300 |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3301 @itemize @bullet{} |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3302 @item |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3303 Assignments inside expressions. |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3304 @item |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3305 Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while} |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3306 (except after a @samp{do @dots{} while} statement); |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3307 @item |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3308 C++ functions with reference parameters. |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3309 @end itemize |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3310 |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3311 @noindent |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3312 You can enable the mode for one buffer with the command @kbd{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3313 cwarn-mode}, or for all suitable buffers with the command @kbd{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3314 global-cwarn-mode} or by customizing the variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3315 @code{global-cwarn-mode}. You must also enable Font Lock mode to make |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3316 it work. |
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3317 |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3318 @item M-x hide-ifdef-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3319 @findex hide-ifdef-mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3320 @cindex Hide-ifdef mode |
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3321 Hide-ifdef minor mode hides selected code within @samp{#if} and |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3322 @samp{#ifdef} preprocessor blocks. See the documentation string of |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3323 @code{hide-ifdef-mode} for more information. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3324 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3325 @item M-x ff-find-related-file |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3326 @cindex related files |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3327 @findex ff-find-related-file |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3328 @vindex ff-related-file-alist |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3329 Find a file ``related'' in a special way to the file visited by the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3330 current buffer. Typically this will be the header file corresponding |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3331 to a C/C++ source file, or vice versa. The variable |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3332 @code{ff-related-file-alist} specifies how to compute related file |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3333 names. |
25829 | 3334 @end table |
3335 | |
3336 @node Comments in C | |
3337 @subsection Comments in C Modes | |
3338 | |
3339 C mode and related modes use a number of variables for controlling | |
3340 comment format. | |
3341 | |
3342 @table @code | |
3343 @item c-comment-only-line-offset | |
3344 @vindex c-comment-only-line-offset | |
3345 Extra offset for line which contains only the start of a comment. It | |
3346 can be either an integer or a cons cell of the form | |
3347 @code{(@var{non-anchored-offset} . @var{anchored-offset})}, where | |
3348 @var{non-anchored-offset} is the amount of offset given to | |
3349 non-column-zero anchored comment-only lines, and @var{anchored-offset} | |
3350 is the amount of offset to give column-zero anchored comment-only lines. | |
3351 Just an integer as value is equivalent to @code{(@var{val} . 0)}. | |
3352 | |
3353 @item c-comment-start-regexp | |
3354 @vindex c-comment-start-regexp | |
3355 This buffer-local variable specifies how to recognize the start of a comment. | |
3356 | |
3357 @item c-hanging-comment-ender-p | |
3358 @vindex c-hanging-comment-ender-p | |
3359 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the | |
3360 comment terminator of a block comment on a line by itself. The default | |
3361 value is @code{t}, which puts the comment-end delimiter @samp{*/} at the | |
3362 end of the last line of the comment text. | |
3363 | |
3364 @item c-hanging-comment-starter-p | |
3365 @vindex c-hanging-comment-starter-p | |
3366 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the | |
3367 starting delimiter of a block comment on a line by itself. The default | |
3368 value is @code{t}, which puts the comment-start delimiter @samp{/*} at | |
3369 the beginning of the first line of the comment text. | |
3370 @end table | |
3371 | |
3372 @node Fortran | |
3373 @section Fortran Mode | |
3374 @cindex Fortran mode | |
3375 @cindex mode, Fortran | |
3376 | |
3377 Fortran mode provides special motion commands for Fortran statements and | |
3378 subprograms, and indentation commands that understand Fortran conventions | |
3379 of nesting, line numbers and continuation statements. Fortran mode has | |
3380 its own Auto Fill mode that breaks long lines into proper Fortran | |
3381 continuation lines. | |
3382 | |
3383 Special commands for comments are provided because Fortran comments | |
3384 are unlike those of other languages. Built-in abbrevs optionally save | |
3385 typing when you insert Fortran keywords. | |
3386 | |
3387 Use @kbd{M-x fortran-mode} to switch to this major mode. This command | |
3388 runs the hook @code{fortran-mode-hook} (@pxref{Hooks}). | |
3389 | |
36263
11db0318031d
Remove redundant index entries.
Eli Zaretskii <eliz@gnu.org>
parents:
36198
diff
changeset
|
3390 @cindex Fortran77 and Fortran90 |
26106 | 3391 @findex f90-mode |
3392 @findex fortran-mode | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3393 Fortan mode is meant for editing Fortran77 ``fixed format'' source |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3394 code. For editing the modern Fortran90 ``free format'' source code, |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3395 use F90 mode (@code{f90-mode}). Emacs normally uses Fortran mode for |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3396 files with extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3397 for the extension @samp{.f90}. GNU Fortran supports both kinds of |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3398 format. |
26106 | 3399 |
25829 | 3400 @menu |
3401 * Motion: Fortran Motion. Moving point by statements or subprograms. | |
3402 * Indent: Fortran Indent. Indentation commands for Fortran. | |
3403 * Comments: Fortran Comments. Inserting and aligning comments. | |
3404 * Autofill: Fortran Autofill. Auto fill minor mode for Fortran. | |
3405 * Columns: Fortran Columns. Measuring columns for valid Fortran. | |
3406 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords. | |
3407 @end menu | |
3408 | |
3409 @node Fortran Motion | |
3410 @subsection Motion Commands | |
3411 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3412 In addition to the normal commands for moving by and operating on |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3413 ``defuns'' (Fortran subprograms---functions and subroutines), Fortran |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3414 mode provides special commands to move by statements. |
25829 | 3415 |
3416 @table @kbd | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3417 @kindex C-c C-n @r{(Fortran mode)} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3418 @findex fortran-next-statement |
25829 | 3419 @item C-c C-n |
3420 Move to beginning of current or next statement | |
3421 (@code{fortran-next-statement}). | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3422 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3423 @kindex C-c C-p @r{(Fortran mode)} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3424 @findex fortran-previous-statement |
25829 | 3425 @item C-c C-p |
3426 Move to beginning of current or previous statement | |
3427 (@code{fortran-previous-statement}). | |
3428 @end table | |
3429 | |
3430 @node Fortran Indent | |
3431 @subsection Fortran Indentation | |
3432 | |
3433 Special commands and features are needed for indenting Fortran code in | |
3434 order to make sure various syntactic entities (line numbers, comment line | |
3435 indicators and continuation line flags) appear in the columns that are | |
3436 required for standard Fortran. | |
3437 | |
3438 @menu | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3439 * Commands: ForIndent Commands. Commands for indenting and filling Fortran. |
25829 | 3440 * Contline: ForIndent Cont. How continuation lines indent. |
3441 * Numbers: ForIndent Num. How line numbers auto-indent. | |
3442 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble. | |
3443 * Vars: ForIndent Vars. Variables controlling Fortran indent style. | |
3444 @end menu | |
3445 | |
3446 @node ForIndent Commands | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3447 @subsubsection Fortran Indentation and Filling Commands |
25829 | 3448 |
3449 @table @kbd | |
3450 @item C-M-j | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3451 Break the current line and set up a continuation line |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3452 (@code{fortran-split-line}). |
25829 | 3453 @item M-^ |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3454 Join this line to the previous line (@code{fortran-join-line}). |
25829 | 3455 @item C-M-q |
3456 Indent all the lines of the subprogram point is in | |
3457 (@code{fortran-indent-subprogram}). | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3458 @item M-q |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3459 Fill a comment block or statement. |
25829 | 3460 @end table |
3461 | |
3462 @kindex C-M-q @r{(Fortran mode)} | |
3463 @findex fortran-indent-subprogram | |
3464 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command | |
3465 to reindent all the lines of the Fortran subprogram (function or | |
3466 subroutine) containing point. | |
3467 | |
3468 @kindex C-M-j @r{(Fortran mode)} | |
3469 @findex fortran-split-line | |
3470 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits | |
3471 a line in the appropriate fashion for Fortran. In a non-comment line, | |
3472 the second half becomes a continuation line and is indented | |
3473 accordingly. In a comment line, both halves become separate comment | |
3474 lines. | |
3475 | |
3476 @kindex M-^ @r{(Fortran mode)} | |
26106 | 3477 @kindex C-c C-d @r{(Fortran mode)} |
3478 @findex fortran-join-line | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3479 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line}, |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3480 which joins a continuation line back to the previous line, roughly as |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3481 the inverse of @code{fortran-split-line}. The point must be on a |
26106 | 3482 continuation line when this command is invoked. |
3483 | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3484 @kindex M-q @r{(Fortran mode)} |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3485 @kbd{M-q} in Fortran mode fills the comment block or statement that |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3486 point is in. This removes any excess statement continuations. |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3487 |
25829 | 3488 @node ForIndent Cont |
3489 @subsubsection Continuation Lines | |
3490 @cindex Fortran continuation lines | |
3491 | |
3492 @vindex fortran-continuation-string | |
3493 Most modern Fortran compilers allow two ways of writing continuation | |
3494 lines. If the first non-space character on a line is in column 5, then | |
3495 that line is a continuation of the previous line. We call this | |
3496 @dfn{fixed format}. (In GNU Emacs we always count columns from 0.) The | |
3497 variable @code{fortran-continuation-string} specifies what character to | |
3498 put on column 5. A line that starts with a tab character followed by | |
3499 any digit except @samp{0} is also a continuation line. We call this | |
3500 style of continuation @dfn{tab format}. | |
3501 | |
3502 @vindex indent-tabs-mode @r{(Fortran mode)} | |
3503 Fortran mode can make either style of continuation line, but you | |
3504 must specify which one you prefer. The value of the variable | |
3505 @code{indent-tabs-mode} controls the choice: @code{nil} for fixed | |
3506 format, and non-@code{nil} for tab format. You can tell which style | |
3507 is presently in effect by the presence or absence of the string | |
3508 @samp{Tab} in the mode line. | |
3509 | |
3510 If the text on a line starts with the conventional Fortran | |
3511 continuation marker @samp{$}, or if it begins with any non-whitespace | |
3512 character in column 5, Fortran mode treats it as a continuation line. | |
3513 When you indent a continuation line with @key{TAB}, it converts the line | |
3514 to the current continuation style. When you split a Fortran statement | |
3515 with @kbd{C-M-j}, the continuation marker on the newline is created | |
3516 according to the continuation style. | |
3517 | |
3518 The setting of continuation style affects several other aspects of | |
3519 editing in Fortran mode. In fixed format mode, the minimum column | |
3520 number for the body of a statement is 6. Lines inside of Fortran | |
3521 blocks that are indented to larger column numbers always use only the | |
3522 space character for whitespace. In tab format mode, the minimum | |
3523 column number for the statement body is 8, and the whitespace before | |
3524 column 8 must always consist of one tab character. | |
3525 | |
3526 @vindex fortran-tab-mode-default | |
3527 @vindex fortran-analyze-depth | |
3528 When you enter Fortran mode for an existing file, it tries to deduce the | |
3529 proper continuation style automatically from the file contents. The first | |
3530 line that begins with either a tab character or six spaces determines the | |
3531 choice. The variable @code{fortran-analyze-depth} specifies how many lines | |
3532 to consider (at the beginning of the file); if none of those lines | |
3533 indicates a style, then the variable @code{fortran-tab-mode-default} | |
3534 specifies the style. If it is @code{nil}, that specifies fixed format, and | |
3535 non-@code{nil} specifies tab format. | |
3536 | |
3537 @node ForIndent Num | |
3538 @subsubsection Line Numbers | |
3539 | |
3540 If a number is the first non-whitespace in the line, Fortran | |
3541 indentation assumes it is a line number and moves it to columns 0 | |
3542 through 4. (Columns always count from 0 in GNU Emacs.) | |
3543 | |
3544 @vindex fortran-line-number-indent | |
3545 Line numbers of four digits or less are normally indented one space. | |
3546 The variable @code{fortran-line-number-indent} controls this; it | |
3547 specifies the maximum indentation a line number can have. Line numbers | |
3548 are indented to right-justify them to end in column 4 unless that would | |
3549 require more than this maximum indentation. The default value of the | |
3550 variable is 1. | |
3551 | |
3552 @vindex fortran-electric-line-number | |
3553 Simply inserting a line number is enough to indent it according to | |
3554 these rules. As each digit is inserted, the indentation is recomputed. | |
3555 To turn off this feature, set the variable | |
3556 @code{fortran-electric-line-number} to @code{nil}. Then inserting line | |
3557 numbers is like inserting anything else. | |
3558 | |
3559 @node ForIndent Conv | |
3560 @subsubsection Syntactic Conventions | |
3561 | |
3562 Fortran mode assumes that you follow certain conventions that simplify | |
3563 the task of understanding a Fortran program well enough to indent it | |
3564 properly: | |
3565 | |
3566 @itemize @bullet | |
3567 @item | |
3568 Two nested @samp{do} loops never share a @samp{continue} statement. | |
3569 | |
3570 @item | |
3571 Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do} | |
3572 and others are written without embedded whitespace or line breaks. | |
3573 | |
3574 Fortran compilers generally ignore whitespace outside of string | |
3575 constants, but Fortran mode does not recognize these keywords if they | |
3576 are not contiguous. Constructs such as @samp{else if} or @samp{end do} | |
3577 are acceptable, but the second word should be on the same line as the | |
3578 first and not on a continuation line. | |
3579 @end itemize | |
3580 | |
3581 @noindent | |
3582 If you fail to follow these conventions, the indentation commands may | |
3583 indent some lines unaesthetically. However, a correct Fortran program | |
3584 retains its meaning when reindented even if the conventions are not | |
3585 followed. | |
3586 | |
3587 @node ForIndent Vars | |
3588 @subsubsection Variables for Fortran Indentation | |
3589 | |
3590 @vindex fortran-do-indent | |
3591 @vindex fortran-if-indent | |
3592 @vindex fortran-structure-indent | |
3593 @vindex fortran-continuation-indent | |
3594 @vindex fortran-check-all-num@dots{} | |
3595 @vindex fortran-minimum-statement-indent@dots{} | |
3596 Several additional variables control how Fortran indentation works: | |
3597 | |
3598 @table @code | |
3599 @item fortran-do-indent | |
3600 Extra indentation within each level of @samp{do} statement (default 3). | |
3601 | |
3602 @item fortran-if-indent | |
3603 Extra indentation within each level of @samp{if} statement (default 3). | |
3604 This value is also used for extra indentation within each level of the | |
3605 Fortran 90 @samp{where} statement. | |
3606 | |
3607 @item fortran-structure-indent | |
3608 Extra indentation within each level of @samp{structure}, @samp{union}, or | |
3609 @samp{map} statements (default 3). | |
3610 | |
3611 @item fortran-continuation-indent | |
3612 Extra indentation for bodies of continuation lines (default 5). | |
3613 | |
3614 @item fortran-check-all-num-for-matching-do | |
3615 If this is @code{nil}, indentation assumes that each @samp{do} statement | |
3616 ends on a @samp{continue} statement. Therefore, when computing | |
3617 indentation for a statement other than @samp{continue}, it can save time | |
3618 by not checking for a @samp{do} statement ending there. If this is | |
3619 non-@code{nil}, indenting any numbered statement must check for a | |
3620 @samp{do} that ends there. The default is @code{nil}. | |
3621 | |
3622 @item fortran-blink-matching-if | |
3623 If this is @code{t}, indenting an @samp{endif} statement moves the | |
3624 cursor momentarily to the matching @samp{if} statement to show where it | |
3625 is. The default is @code{nil}. | |
3626 | |
3627 @item fortran-minimum-statement-indent-fixed | |
3628 Minimum indentation for fortran statements when using fixed format | |
3629 continuation line style. Statement bodies are never indented less than | |
3630 this much. The default is 6. | |
3631 | |
3632 @item fortran-minimum-statement-indent-tab | |
3633 Minimum indentation for fortran statements for tab format continuation line | |
3634 style. Statement bodies are never indented less than this much. The | |
3635 default is 8. | |
3636 @end table | |
3637 | |
3638 @node Fortran Comments | |
3639 @subsection Fortran Comments | |
3640 | |
3641 The usual Emacs comment commands assume that a comment can follow a line | |
3642 of code. In Fortran, the standard comment syntax requires an entire line | |
3643 to be just a comment. Therefore, Fortran mode replaces the standard Emacs | |
3644 comment commands and defines some new variables. | |
3645 | |
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3646 Fortran mode can also handle the Fortran90 comment syntax where comments |
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3647 start with @samp{!} and can follow other text. Because only some Fortran77 |
25829 | 3648 compilers accept this syntax, Fortran mode will not insert such comments |
3649 unless you have said in advance to do so. To do this, set the variable | |
3650 @code{comment-start} to @samp{"!"} (@pxref{Variables}). | |
3651 | |
3652 @table @kbd | |
3653 @item M-; | |
3654 Align comment or insert new comment (@code{fortran-comment-indent}). | |
3655 | |
3656 @item C-x ; | |
3657 Applies to nonstandard @samp{!} comments only. | |
3658 | |
3659 @item C-c ; | |
3660 Turn all lines of the region into comments, or (with argument) turn them back | |
3661 into real code (@code{fortran-comment-region}). | |
3662 @end table | |
3663 | |
3664 @kbd{M-;} in Fortran mode is redefined as the command | |
3665 @code{fortran-comment-indent}. Like the usual @kbd{M-;} command, this | |
3666 recognizes any kind of existing comment and aligns its text appropriately; | |
3667 if there is no existing comment, a comment is inserted and aligned. But | |
3668 inserting and aligning comments are not the same in Fortran mode as in | |
3669 other modes. | |
3670 | |
3671 When a new comment must be inserted, if the current line is blank, a | |
3672 full-line comment is inserted. On a non-blank line, a nonstandard @samp{!} | |
3673 comment is inserted if you have said you want to use them. Otherwise a | |
3674 full-line comment is inserted on a new line before the current line. | |
3675 | |
3676 Nonstandard @samp{!} comments are aligned like comments in other | |
3677 languages, but full-line comments are different. In a standard full-line | |
3678 comment, the comment delimiter itself must always appear in column zero. | |
3679 What can be aligned is the text within the comment. You can choose from | |
3680 three styles of alignment by setting the variable | |
3681 @code{fortran-comment-indent-style} to one of these values: | |
3682 | |
3683 @vindex fortran-comment-indent-style | |
3684 @vindex fortran-comment-line-extra-indent | |
3685 @table @code | |
3686 @item fixed | |
3687 Align the text at a fixed column, which is the sum of | |
3688 @code{fortran-comment-line-extra-indent} and the minimum statement | |
3689 indentation. This is the default. | |
3690 | |
3691 The minimum statement indentation is | |
3692 @code{fortran-minimum-statement-indent-fixed} for fixed format | |
3693 continuation line style and @code{fortran-minimum-statement-indent-tab} | |
3694 for tab format style. | |
3695 | |
3696 @item relative | |
3697 Align the text as if it were a line of code, but with an additional | |
3698 @code{fortran-comment-line-extra-indent} columns of indentation. | |
3699 | |
3700 @item nil | |
3701 Don't move text in full-line comments automatically at all. | |
3702 @end table | |
3703 | |
3704 @vindex fortran-comment-indent-char | |
3705 In addition, you can specify the character to be used to indent within | |
3706 full-line comments by setting the variable | |
3707 @code{fortran-comment-indent-char} to the single-character string you want | |
3708 to use. | |
3709 | |
3710 @vindex comment-line-start | |
3711 @vindex comment-line-start-skip | |
3712 Fortran mode introduces two variables @code{comment-line-start} and | |
3713 @code{comment-line-start-skip}, which play for full-line comments the same | |
3714 roles played by @code{comment-start} and @code{comment-start-skip} for | |
3715 ordinary text-following comments. Normally these are set properly by | |
3716 Fortran mode, so you do not need to change them. | |
3717 | |
3718 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If | |
3719 you use @samp{!} comments, this command can be used with them. Otherwise | |
3720 it is useless in Fortran mode. | |
3721 | |
3722 @kindex C-c ; @r{(Fortran mode)} | |
3723 @findex fortran-comment-region | |
3724 @vindex fortran-comment-region | |
3725 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the | |
3726 lines of the region into comments by inserting the string @samp{C$$$} at | |
3727 the front of each one. With a numeric argument, it turns the region | |
3728 back into live code by deleting @samp{C$$$} from the front of each line | |
3729 in it. The string used for these comments can be controlled by setting | |
3730 the variable @code{fortran-comment-region}. Note that here we have an | |
3731 example of a command and a variable with the same name; these two uses | |
3732 of the name never conflict because in Lisp and in Emacs it is always | |
3733 clear from the context which one is meant. | |
3734 | |
3735 @node Fortran Autofill | |
3736 @subsection Fortran Auto Fill Mode | |
3737 | |
3738 Fortran Auto Fill mode is a minor mode which automatically splits | |
3739 Fortran statements as you insert them when they become too wide. | |
3740 Splitting a statement involves making continuation lines using | |
3741 @code{fortran-continuation-string} (@pxref{ForIndent Cont}). This | |
3742 splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and | |
3743 also in the Fortran indentation commands. | |
3744 | |
3745 @findex fortran-auto-fill-mode | |
3746 @kbd{M-x fortran-auto-fill-mode} turns Fortran Auto Fill mode on if it | |
3747 was off, or off if it was on. This command works the same as @kbd{M-x | |
3748 auto-fill-mode} does for normal Auto Fill mode (@pxref{Filling}). A | |
3749 positive numeric argument turns Fortran Auto Fill mode on, and a | |
3750 negative argument turns it off. You can see when Fortran Auto Fill mode | |
3751 is in effect by the presence of the word @samp{Fill} in the mode line, | |
3752 inside the parentheses. Fortran Auto Fill mode is a minor mode, turned | |
3753 on or off for each buffer individually. @xref{Minor Modes}. | |
3754 | |
3755 @vindex fortran-break-before-delimiters | |
3756 Fortran Auto Fill mode breaks lines at spaces or delimiters when the | |
3757 lines get longer than the desired width (the value of @code{fill-column}). | |
3758 The delimiters that Fortran Auto Fill mode may break at are @samp{,}, | |
3759 @samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}. | |
3760 The line break comes after the delimiter if the variable | |
3761 @code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by | |
3762 default), the break comes before the delimiter. | |
3763 | |
3764 By default, Fortran Auto Fill mode is not enabled. If you want this | |
3765 feature turned on permanently, add a hook function to | |
3766 @code{fortran-mode-hook} to execute @code{(fortran-auto-fill-mode 1)}. | |
3767 @xref{Hooks}. | |
3768 | |
3769 @node Fortran Columns | |
3770 @subsection Checking Columns in Fortran | |
3771 | |
3772 @table @kbd | |
3773 @item C-c C-r | |
3774 Display a ``column ruler'' momentarily above the current line | |
3775 (@code{fortran-column-ruler}). | |
3776 @item C-c C-w | |
3777 Split the current window horizontally temporarily so that it is 72 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3778 columns wide (@code{fortran-window-create-momentarily}). This may |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3779 help you avoid making lines longer than the 72-character limit that |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3780 some Fortran compilers impose. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3781 @item C-u C-c C-w |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3782 Split the current window horizontally so that it is 72 columns wide |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3783 (@code{fortran-window-create}). You can then continue editing. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3784 @item M-x fortran-strip-sequence-nos |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3785 Delete all text in column 72 and beyond. |
25829 | 3786 @end table |
3787 | |
3788 @kindex C-c C-r @r{(Fortran mode)} | |
3789 @findex fortran-column-ruler | |
3790 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column | |
3791 ruler momentarily above the current line. The comment ruler is two lines | |
3792 of text that show you the locations of columns with special significance in | |
3793 Fortran programs. Square brackets show the limits of the columns for line | |
3794 numbers, and curly brackets show the limits of the columns for the | |
3795 statement body. Column numbers appear above them. | |
3796 | |
3797 Note that the column numbers count from zero, as always in GNU Emacs. | |
3798 As a result, the numbers may be one less than those you are familiar | |
3799 with; but the positions they indicate in the line are standard for | |
3800 Fortran. | |
3801 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3802 @vindex fortran-column-ruler-fixed |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3803 @vindex fortran-column-ruler-tabs |
26264 | 3804 The text used to display the column ruler depends on the value of |
25829 | 3805 the variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is |
3806 @code{nil}, then the value of the variable | |
3807 @code{fortran-column-ruler-fixed} is used as the column ruler. | |
3808 Otherwise, the variable @code{fortran-column-ruler-tab} is displayed. | |
3809 By changing these variables, you can change the column ruler display. | |
3810 | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3811 @kindex C-c C-w @r{(Fortran mode)} |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3812 @findex fortran-window-create-momentarily |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3813 @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3814 splits the current window horizontally, making a window 72 columns |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3815 wide, so you can see which lines that is too long. Type a space to |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3816 restore the normal width. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3817 |
26106 | 3818 @kindex C-u C-c C-w @r{(Fortran mode)} |
25829 | 3819 @findex fortran-window-create |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3820 You can also split the window horizontally and continue editing with |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3821 the split in place. To do this, use @kbd{C-u C-c C-w} (@code{M-x |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3822 fortran-window-create}). By editing in this window you can |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3823 immediately see when you make a line too wide to be correct Fortran. |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3824 |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3825 @findex fortran-strip-sequence-nos |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3826 The command @kbd{M-x fortran-strip-sequence-nos} deletes all text in |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3827 column 72 and beyond, on all lines in the current buffer. This is the |
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3828 easiest way to get rid of old sequence numbers. |
26106 | 3829 |
25829 | 3830 @node Fortran Abbrev |
3831 @subsection Fortran Keyword Abbrevs | |
3832 | |
3833 Fortran mode provides many built-in abbrevs for common keywords and | |
3834 declarations. These are the same sort of abbrev that you can define | |
3835 yourself. To use them, you must turn on Abbrev mode. @xref{Abbrevs}. | |
3836 | |
3837 The built-in abbrevs are unusual in one way: they all start with a | |
3838 semicolon. You cannot normally use semicolon in an abbrev, but Fortran | |
3839 mode makes this possible by changing the syntax of semicolon to ``word | |
3840 constituent.'' | |
3841 | |
3842 For example, one built-in Fortran abbrev is @samp{;c} for | |
3843 @samp{continue}. If you insert @samp{;c} and then insert a punctuation | |
3844 character such as a space or a newline, the @samp{;c} expands automatically | |
3845 to @samp{continue}, provided Abbrev mode is enabled.@refill | |
3846 | |
3847 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in | |
3848 Fortran abbrevs and what they stand for. | |
3849 | |
3850 @node Asm Mode | |
3851 @section Asm Mode | |
3852 | |
3853 @cindex Asm mode | |
36183
d3f65290e6b2
Clean up comment-dwim vs indent-for-comment, etc.
Richard M. Stallman <rms@gnu.org>
parents:
35477
diff
changeset
|
3854 @cindex assembler mode |
25829 | 3855 Asm mode is a major mode for editing files of assembler code. It |
3856 defines these commands: | |
3857 | |
3858 @table @kbd | |
3859 @item @key{TAB} | |
3860 @code{tab-to-tab-stop}. | |
3861 @item C-j | |
3862 Insert a newline and then indent using @code{tab-to-tab-stop}. | |
3863 @item : | |
3864 Insert a colon and then remove the indentation from before the label | |
3865 preceding colon. Then do @code{tab-to-tab-stop}. | |
3866 @item ; | |
3867 Insert or align a comment. | |
3868 @end table | |
3869 | |
3870 The variable @code{asm-comment-char} specifies which character | |
3871 starts comments in assembler syntax. |